From 19ae81f1dc3c4d9bc35de2948e055f40ebb769b0 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 1 Aug 2017 15:04:17 -0400 Subject: [PATCH] Request a small MSS in web connection explicitly Sometimes equipment will not handle some header data, such as 802.1q tag. Other times, there's a jumbo NIC talking to a BMC that is not jumbo. Workaround such situations by setting the MSS to 1456 explicitly, which fits in MTU 1500 plus 4 bytes for dot1q tag, if some intermediat device fails to handle that. Change-Id: I7db1c8feac1c094871723026771792432a3daaf4 --- pyghmi/util/webclient.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyghmi/util/webclient.py b/pyghmi/util/webclient.py index c4533b56..19503d42 100644 --- a/pyghmi/util/webclient.py +++ b/pyghmi/util/webclient.py @@ -81,7 +81,13 @@ class SecureHTTPConnection(httplib.HTTPConnection, object): self.stdheaders[key] = value def connect(self): - plainsock = socket.create_connection((self.host, self.port), 60) + addrinfo = socket.getaddrinfo(self.host, self.port)[0] + # workaround problems of too large mtu, moderately frequent occurance + # in this space + plainsock = socket.socket(addrinfo[0]) + plainsock.settimeout(60) + plainsock.setsockopt(socket.IPPROTO_TCP, socket.TCP_MAXSEG, 1456) + plainsock.connect(addrinfo[4]) self.sock = ssl.wrap_socket(plainsock, cert_reqs=self.cert_reqs) # txtcert = self.sock.getpeercert() # currently not possible bincert = self.sock.getpeercert(binary_form=True)