[ovs-dev] [PATCH] utilities: Implement ovs-vlan-test script
Ethan Jackson
ethan at nicira.com
Thu Dec 16 18:44:31 UTC 2010
> What version(s) of Python did you try this with? Does it work as far
> back as the Python 2.4 installed on XenServer 5.5.0?
Yep I tried it on python 2.4 hence some of the weirdness mentioned below.
> Do we have any way to verify that the OS isn't adding anything else,
> e.g. adding IP options etc.? (Does it matter if it does?)
>
That would probably matter because MTU sized packets would be too big
and get fragmented. In my testing nothing like that was happening. I
suppose I could have the server verify the size of the packet on
receipt and fail the test if it's not correct.
>> + packet = [chr(0) for _ in range(length)]
>> + data_str = str(key)
>> +
>> + for i in range(len(data_str)):
>> + packet[i] = data_str[i]
>> + packet = ''.join(packet)
>
> Yowza, is that really the best way to construct a packet in Python? I
> had to read it a few times.
No this isn't really the best way to do it in python. What you really
want is a bytearray. Unfortunately python 2.4 doesn't support byte
arrays so I had to change to this extremely awkward string
manipulation.
I could probably write this simpler by just appending chr(0) to
data_str. I'll do that cause it's probably easier to read.
>
> (The _ shows your functional programming background :-)
Haha I had *way* more closures in earlier versions of the patch.
Turns out they don't work very well in python =).
I'll make the man page changes you suggested and re-send the patch.
Ethan
More information about the dev
mailing list