This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add formal support for UDPLITE protocol
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, gappleto97, miss-islington
Priority: normal Keywords: patch

Created on 2019-06-20 06:35 by gappleto97, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 14258 merged gappleto97, 2019-06-20 06:37
Messages (10)
msg346103 - (view) Author: Gabe Appleton (gappleto97) * Date: 2019-06-20 06:35
At the moment you can definitely use UDPLITE sockets on Linux systems, but it would be good if this support were formalized such that you can detect support at runtime easily.

At the moment, to make and use a UDPLITE socket requires something like the following code:

>>> import socket
>>> a = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 136)
>>> b = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 136)
>>> a.bind(('localhost', 44444))
>>> b.sendto(b'test'*256, ('localhost', 44444))
>>> b.setsockopt(136, 10, 16)
>>> b.sendto(b'test'*256, ('localhost', 44444))
>>> b.setsockopt(136, 10, 32)
>>> b.sendto(b'test'*256, ('localhost', 44444))
>>> b.setsockopt(136, 10, 64)
>>> b.sendto(b'test'*256, ('localhost', 44444))

If you look at this through Wireshark, you can see that the packets are different in that the checksums and checksum coverages change.

With the pull request that I am submitting momentarily, you could do the following code instead:

>>> import socket
>>> a = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDPLITE)
>>> b = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDPLITE)
>>> a.bind(('localhost', 44444))
>>> b.sendto(b'test'*256, ('localhost', 44444))
>>> b.set_send_checksum_coverage(16)
>>> b.sendto(b'test'*256, ('localhost', 44444))
>>> b.set_send_checksum_coverage(32)
>>> b.sendto(b'test'*256, ('localhost', 44444))
>>> b.set_send_checksum_coverage(64)
>>> b.sendto(b'test'*256, ('localhost', 44444))

One can also detect support for UDPLITE just by checking

>>> hasattr(socket, 'IPPROTO_UDPLITE')
msg346112 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-06-20 10:54
Adding new constants like socket.IPPROTO_UDPLITE is fine.
The question is: why we need a new function?
There is no set_send_checksum_coverage() on C level IIRC
msg346120 - (view) Author: Gabe Appleton (gappleto97) * Date: 2019-06-20 14:11
Its true that this doesnt exist at the C level, however I worry that having it purely through getsockopt() and setsockopt() would make things more confusing, so I added it as a helper function.

I can remove it in lieu of documentation if that would block merging, though I dont think that is the right move here.

On June 20, 2019 10:54:58 AM UTC, Andrew Svetlov <report@bugs.python.org> wrote:
>
>Andrew Svetlov <andrew.svetlov@gmail.com> added the comment:
>
>Adding new constants like socket.IPPROTO_UDPLITE is fine.
>The question is: why we need a new function?
>There is no set_send_checksum_coverage() on C level IIRC
>
>----------
>nosy: +asvetlov
>
>_______________________________________
>Python tracker <report@bugs.python.org>
><https://bugs.python.org/issue37345>
>_______________________________________
msg346182 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-06-21 04:32
We have no setsockopt() shortcut helpers.
socket.setblocking() uses fcntl() internally.
msg346183 - (view) Author: Gabe Appleton (gappleto97) * Date: 2019-06-21 04:50
I just want to be explicit so I don't mess up on protocol, since I am new to this project. Does that mean that you want me to remove the helper function and put documentation in about that sockopt, or that an exception could be made in this case?
msg346188 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-06-21 07:37
Sorry.
Please drop helper methods but keep IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV, UDPLITE_RECV_CSCOV constants.
msg346269 - (view) Author: Gabe Appleton (gappleto97) * Date: 2019-06-22 03:45
Okay, I removed the helper functions and added some additional documentation. Does that look okay now?
msg346272 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-06-22 08:26
3.8 is in beta stage, public API is frozen
msg346283 - (view) Author: Gabe Appleton (gappleto97) * Date: 2019-06-22 15:54
I didn't realize that when I submitted this the first time, but I corrected that in the documentation when someone else removed it from the tags. If I re-added it it was by mistake. I notice that my browser had that auto-highlighted. Should be fixed now.
msg346361 - (view) Author: miss-islington (miss-islington) Date: 2019-06-24 09:59
New changeset 2ac3bab2a6e1f9e17fc0c58a26e8425bb93cb0f5 by Miss Islington (bot) (Gabe Appleton) in branch 'master':
bpo-37345: Add formal UDPLITE support (GH-14258)
https://github.com/python/cpython/commit/2ac3bab2a6e1f9e17fc0c58a26e8425bb93cb0f5
History
Date User Action Args
2022-04-11 14:59:16adminsetgithub: 81526
2019-06-24 09:59:46asvetlovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-06-24 09:59:01miss-islingtonsetnosy: + miss-islington
messages: + msg346361
2019-06-22 15:54:15gappleto97setmessages: + msg346283
2019-06-22 08:26:52asvetlovsetmessages: + msg346272
2019-06-22 08:26:08asvetlovsetversions: - Python 3.8
2019-06-22 07:13:54serhiy.storchakasettitle: Add formal support for UDPLITE protococl -> Add formal support for UDPLITE protocol
2019-06-22 03:45:57gappleto97setmessages: + msg346269
versions: + Python 3.8
2019-06-21 07:37:38asvetlovsetmessages: + msg346188
2019-06-21 04:50:54gappleto97setmessages: + msg346183
2019-06-21 04:32:34asvetlovsetmessages: + msg346182
2019-06-20 14:11:23gappleto97setmessages: + msg346120
2019-06-20 10:54:58asvetlovsetnosy: + asvetlov
messages: + msg346112
2019-06-20 06:49:49serhiy.storchakasetversions: - Python 3.8
2019-06-20 06:37:53gappleto97setkeywords: + patch
stage: patch review
pull_requests: + pull_request14088
2019-06-20 06:35:47gappleto97create