)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"02b2c7254e20fe27314b212bc3a5943a6752dfc2","unresolved":true,"context_lines":[{"line_number":6,"context_line":""},{"line_number":7,"context_line":"Remove hard dependency on netifaces"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"The project was archived in 2021, and we can fairly easily replace it"},{"line_number":10,"context_line":"with some ctypes code to call getifaddrs ourselves."},{"line_number":11,"context_line":""},{"line_number":12,"context_line":"Be willing to fall back to netifaces (with a warning) in case getifaddrs"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":7,"id":"8bb2b160_8dcbb6fb","line":9,"range":{"start_line":9,"start_character":45,"end_line":9,"end_character":58},"updated":"2023-05-22 22:59:14.000000000","message":"Famous last words...","commit_id":"4de8516326f92c1b98756afded932fc6984a2c96"}],"/PATCHSET_LEVEL":[{"author":{"_account_id":597,"name":"Pete Zaitcev","email":"zaitcev@kotori.zaitcev.us","username":"zaitcev"},"change_message_id":"5d409f18fcc9adde54d205215f095e68e0591bfb","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":3,"id":"b6832d37_a55c99b6","updated":"2023-02-09 23:03:52.000000000","message":"Did you consider ifaddr?\nhttps://pypi.org/project/ifaddr/\n","commit_id":"c58c67279ba35c74377aa3778fe2f2a917fc01e9"},{"author":{"_account_id":597,"name":"Pete Zaitcev","email":"zaitcev@kotori.zaitcev.us","username":"zaitcev"},"change_message_id":"42247588e43200e967ed8cd9faf84998df278262","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":4,"id":"ab8c6f8c_88d6a46a","updated":"2023-05-11 21:41:34.000000000","message":"I have to wag my finger at modifying the code simultaneously with moving it from file to file, but I see no bugs in the newly-added code (getifaddrs).","commit_id":"402f493ad0d4732e4da2d227e21e351554d58b8f"},{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"21ac675cffb6f2cb9ae04cdc51d7d3d9b609e40f","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":4,"id":"0e1f26c2_e246bbd5","updated":"2023-05-19 18:11:22.000000000","message":"I need to fix up the `sa_family`/`sin_port` issue, both so this works on big endian architectures (which I guess there\u0027s some appetite for? See https://bugs.launchpad.net/swift/+bug/1639980 for example.) *and* so we don\u0027t go insane the next time we have reason to look at this code.","commit_id":"402f493ad0d4732e4da2d227e21e351554d58b8f"},{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"74b3cdf22d884d6ecf927efcea9b2fa30e92df22","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":4,"id":"803cf505_d62db6ca","updated":"2023-05-19 07:13:16.000000000","message":"as an initial parse this looks good. Just want to confirm it works as I put it through it\u0027s paces.\n\nThe c code is coming directly from the archived netifaces module I aussume?.. are there any tests we can steal from there.. I guess it\u0027s just pulling ips, so maybe we have it covered in our existing tests.\n\nJust commenting to let you know I havne\u0027t forgotten, just got distracted with a downstream problem while I was looking into this patch.. will finish the proper review on Monday, it\u0027s at the top of my TODO.","commit_id":"402f493ad0d4732e4da2d227e21e351554d58b8f"},{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"2fc4a11861ca3bce826a8ccf9f3f364baf599eb5","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":4,"id":"75389713_249e5eea","updated":"2023-05-11 21:02:23.000000000","message":"check experimental","commit_id":"402f493ad0d4732e4da2d227e21e351554d58b8f"},{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"21ac675cffb6f2cb9ae04cdc51d7d3d9b609e40f","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":4,"id":"a4a549cc_c704e35c","in_reply_to":"803cf505_d62db6ca","updated":"2023-05-19 18:11:22.000000000","message":"\u003e The c code is coming directly from the archived netifaces module I aussume?\n\nYeah, see https://github.com/al45tair/netifaces/blob/master/netifaces.c#L1014-L1127 -- though in actuality, I think I may have just skimmed it to determine roughly how it did its thing, then read https://www.man7.org/linux/man-pages/man3/getifaddrs.3.html and lightly cribbed from the example there.\n\nI\u0027ve still got a few questions in my own mind, though -- it seems like there should be some (unused) port info in those addr structs? Maybe I made the family field too wide...","commit_id":"402f493ad0d4732e4da2d227e21e351554d58b8f"},{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"c29d91b9c7db5663c011bd5adba59804f478a1d0","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":4,"id":"94e69ea9_8ba816b0","in_reply_to":"ab8c6f8c_88d6a46a","updated":"2023-05-16 19:21:36.000000000","message":"Yeah, sorry -- I started out wanting to drop the dep, wrote a bunch of `ctypes` code in a separate file to try it out, then decided I ought to pull more things out. I could probably pull it apart into two patches: first extract from utils, then drop dep.","commit_id":"402f493ad0d4732e4da2d227e21e351554d58b8f"},{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"ec6d21fd683b45b6067354471781b02d21cb6d6b","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":7,"id":"90864b75_428b31f8","updated":"2023-05-22 17:55:29.000000000","message":"Broke it up as two separate patches. Also tagging in Alistair, since he was seeing test failures running on his OS X host; I think those should be fixed now (and for other BSDs? 🤞)","commit_id":"4de8516326f92c1b98756afded932fc6984a2c96"},{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"fea4d67be74bad017f9204c9e9820d594cab755b","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":8,"id":"86d726d9_2fb136b7","updated":"2023-05-24 07:03:42.000000000","message":"@Al, maybe you can do the same on your mac (the ipython) just to make sure it\u0027s working for you before a +A too?","commit_id":"23fa18d3021fb44d8b4dd81890d9c355eed9426f"},{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"f75cf84355e6c29b35aed8a7b8df109b35a9cae6","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":8,"id":"0e5d38d8_16928700","updated":"2023-05-24 07:00:04.000000000","message":"Love it, great work Tim\n\nFrom my VSAIO:\n\n    In [1]: from swift.common.utils.ipaddrs import whataremyips\n    In [2]: whataremyips()\n    Out[2]: \n    [\u0027127.0.0.1\u0027,\n     \u002710.0.2.15\u0027,\n     \u0027192.168.8.88\u0027,\n     \u0027172.17.0.1\u0027,\n     \u0027::1\u0027,\n     \u0027fe80::15:54ff:fe75:57bf\u0027,\n     \u0027fe80::a00:27ff:fe7e:5a0e\u0027]\n    In [3]: !ip a\n    1: lo: \u003cLOOPBACK,UP,LOWER_UP\u003e mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000\n        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00\n        inet 127.0.0.1/8 scope host lo\n           valid_lft forever preferred_lft forever\n        inet6 ::1/128 scope host \n           valid_lft forever preferred_lft forever\n    2: enp0s3: \u003cBROADCAST,MULTICAST,UP,LOWER_UP\u003e mtu 1500 qdisc fq_codel state UP group default qlen 1000\n        link/ether 02:15:54:75:57:bf brd ff:ff:ff:ff:ff:ff\n        inet 10.0.2.15/24 metric 100 brd 10.0.2.255 scope global dynamic enp0s3\n           valid_lft 79924sec preferred_lft 79924sec\n        inet6 fe80::15:54ff:fe75:57bf/64 scope link \n           valid_lft forever preferred_lft forever\n    3: enp0s8: \u003cBROADCAST,MULTICAST,UP,LOWER_UP\u003e mtu 1500 qdisc fq_codel state UP group default qlen 1000\n        link/ether 08:00:27:7e:5a:0e brd ff:ff:ff:ff:ff:ff\n        inet 192.168.8.88/24 brd 192.168.8.255 scope global enp0s8\n           valid_lft forever preferred_lft forever\n        inet6 fe80::a00:27ff:fe7e:5a0e/64 scope link \n           valid_lft forever preferred_lft forever\n    4: docker0: \u003cNO-CARRIER,BROADCAST,MULTICAST,UP\u003e mtu 1500 qdisc noqueue state DOWN group default \n        link/ether 02:42:4c:55:ba:d0 brd ff:ff:ff:ff:ff:ff\n        inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0\n           valid_lft forever preferred_lft forever\n\nSo the casting to the sockaddr_in6 is working fine!\n\nAnd some working on my laptop with more interfaces.\n\nLeft one question in there, whether we should just include the netmask field incase we ever want to pull it out or need the data in the future. But we dont use it now, so could just we something to add when and if we need it. (so long as we remember the field is there, just cut off).\nSo will leave off the +A until a response.. otherwise I\u0027ll come in on my morning (during the meeting) to apply the +A. Great job.","commit_id":"23fa18d3021fb44d8b4dd81890d9c355eed9426f"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"9f8b1dcb0cfb63e8365184dc8b2c5b95af23040b","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":8,"id":"e4d43c64_685d1973","updated":"2023-05-24 09:42:55.000000000","message":"tests pass on macos\n\n```\n(swift-3.8.15) (acoles) ~/0dev/openstack/swift{review/tim_burke/remove-netifaces,+} % uname -a\nDarwin acoles-mlt 21.6.0 Darwin Kernel Version 21.6.0: Thu Mar  9 20:12:21 PST 2023; root:xnu-8020.240.18.700.8~1/RELEASE_ARM64_T6000 arm64\n(swift-3.8.15) (acoles) ~/0dev/openstack/swift{review/tim_burke/remove-netifaces,+} % pytest test/unit/common/utils/test_ipaddrs.py\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d test session starts \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\nplatform darwin -- Python 3.8.15, pytest-7.2.0, pluggy-1.0.0 -- /Users/acoles/.pyenv/versions/3.8.15/envs/swift-3.8.15/bin/python3.8\ncachedir: .pytest_cache\nrootdir: /Users/acoles/0dev/openstack/swift, configfile: tox.ini\nplugins: cov-4.0.0\ncollected 10 items\n\ntest/unit/common/utils/test_ipaddrs.py::TestIsValidIP::test_is_valid_ip PASSED                                                                      [ 10%]\ntest/unit/common/utils/test_ipaddrs.py::TestIsValidIP::test_is_valid_ipv4 PASSED                                                                    [ 20%]\ntest/unit/common/utils/test_ipaddrs.py::TestIsValidIP::test_is_valid_ipv6 PASSED                                                                    [ 30%]\ntest/unit/common/utils/test_ipaddrs.py::TestExpandIPv6::test_expand_ipv6 PASSED                                                                     [ 40%]\ntest/unit/common/utils/test_ipaddrs.py::TestWhatAreMyIPs::test_whataremyips PASSED                                                                  [ 50%]\ntest/unit/common/utils/test_ipaddrs.py::TestWhatAreMyIPs::test_whataremyips_bind_ip_specific PASSED                                                 [ 60%]\ntest/unit/common/utils/test_ipaddrs.py::TestWhatAreMyIPs::test_whataremyips_bind_to_all PASSED                                                      [ 70%]\ntest/unit/common/utils/test_ipaddrs.py::TestWhatAreMyIPs::test_whataremyips_getifaddrs PASSED                                                       [ 80%]\ntest/unit/common/utils/test_ipaddrs.py::TestWhatAreMyIPs::test_whataremyips_netifaces_error PASSED                                                  [ 90%]\ntest/unit/common/utils/test_ipaddrs.py::TestWhatAreMyIPs::test_whataremyips_netifaces_ipv6 PASSED                                                   [100%]\n\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d 10 passed in 0.24s \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n```\n\nand comparison with netifaces result is OK:\n\n```\n(swift-3.8.15) (acoles) ~/0dev/openstack/swift{review/tim_burke/remove-netifaces,+} % python\nPython 3.8.15 (default, Dec 19 2022, 14:57:48)\n[Clang 14.0.0 (clang-1400.0.29.202)] on darwin\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u003e\u003e\u003e import swift.common.utils.ipaddrs as ipaddrs\n\u003e\u003e\u003e x \u003d ipaddrs.whataremyips()\n\u003e\u003e\u003e ipaddrs.getifaddrs \u003d None\n\u003e\u003e\u003e import netifaces\n\u003e\u003e\u003e ipaddrs.netifaces \u003d netifaces\n\u003e\u003e\u003e y \u003d ipaddrs.whataremyips()\n\u003e\u003e\u003e sorted(x) \u003d\u003d sorted(y)\nTrue\n```","commit_id":"23fa18d3021fb44d8b4dd81890d9c355eed9426f"}],"swift/common/utils.py":[{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"92291e8724b6b99856ddfc8e08cbee1db6ceb70d","unresolved":true,"context_lines":[{"line_number":2777,"context_line":"    else:"},{"line_number":2778,"context_line":"        # `ip` is available, or at least, netifaces *is not*"},{"line_number":2779,"context_line":"        interface_data \u003d json.loads(subprocess.check_output(["},{"line_number":2780,"context_line":"            \"ip\", \"-j\", \"addr\", \"show\"]))"},{"line_number":2781,"context_line":"        for interface in interface_data:"},{"line_number":2782,"context_line":"            for address in interface[\u0027addr_info\u0027]:"},{"line_number":2783,"context_line":"                if address[\u0027family\u0027] not in (\u0027inet\u0027, \u0027inet6\u0027):"}],"source_content_type":"text/x-python","patch_set":2,"id":"fb7eb80a_cff49625","line":2780,"updated":"2023-02-09 20:39:10.000000000","message":":-/ iproute 4.11 (used by centos7 at least) doesn\u0027t support JSON output...","commit_id":"c131638f52a445e6561d962e20493a8bab6a618d"},{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"801d00054e4048ced2e44271b2461037506e4e78","unresolved":false,"context_lines":[{"line_number":2777,"context_line":"    else:"},{"line_number":2778,"context_line":"        # `ip` is available, or at least, netifaces *is not*"},{"line_number":2779,"context_line":"        interface_data \u003d json.loads(subprocess.check_output(["},{"line_number":2780,"context_line":"            \"ip\", \"-j\", \"addr\", \"show\"]))"},{"line_number":2781,"context_line":"        for interface in interface_data:"},{"line_number":2782,"context_line":"            for address in interface[\u0027addr_info\u0027]:"},{"line_number":2783,"context_line":"                if address[\u0027family\u0027] not in (\u0027inet\u0027, \u0027inet6\u0027):"}],"source_content_type":"text/x-python","patch_set":2,"id":"36881a3b_c09c3359","line":2780,"in_reply_to":"fb7eb80a_cff49625","updated":"2023-05-23 21:35:41.000000000","message":"Done","commit_id":"c131638f52a445e6561d962e20493a8bab6a618d"}],"swift/common/utils/ipaddrs.py":[{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"21ac675cffb6f2cb9ae04cdc51d7d3d9b609e40f","unresolved":true,"context_lines":[{"line_number":124,"context_line":"else:"},{"line_number":125,"context_line":"    class sockaddr(ctypes.Structure):"},{"line_number":126,"context_line":"        _fields_ \u003d ["},{"line_number":127,"context_line":"            (\"sa_family\", ctypes.c_int),"},{"line_number":128,"context_line":"            (\"sa_ipv4\", ctypes.c_ubyte * 4),"},{"line_number":129,"context_line":"            # For AF_INET6, ^^^ becomes... flowinfo, I think?"},{"line_number":130,"context_line":"            # Seems to usually be zeroed out"}],"source_content_type":"text/x-python","patch_set":4,"id":"8980db45_187aa4f5","line":127,"range":{"start_line":127,"start_character":33,"end_line":127,"end_character":38},"updated":"2023-05-19 18:11:22.000000000","message":"Ah! `sa_family` is actually just 16 bits! So there\u0027s still some bits that should be labeled `sin_port`...","commit_id":"402f493ad0d4732e4da2d227e21e351554d58b8f"},{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"801d00054e4048ced2e44271b2461037506e4e78","unresolved":false,"context_lines":[{"line_number":124,"context_line":"else:"},{"line_number":125,"context_line":"    class sockaddr(ctypes.Structure):"},{"line_number":126,"context_line":"        _fields_ \u003d ["},{"line_number":127,"context_line":"            (\"sa_family\", ctypes.c_int),"},{"line_number":128,"context_line":"            (\"sa_ipv4\", ctypes.c_ubyte * 4),"},{"line_number":129,"context_line":"            # For AF_INET6, ^^^ becomes... flowinfo, I think?"},{"line_number":130,"context_line":"            # Seems to usually be zeroed out"}],"source_content_type":"text/x-python","patch_set":4,"id":"471992e2_832e6b75","line":127,"range":{"start_line":127,"start_character":33,"end_line":127,"end_character":38},"in_reply_to":"8980db45_187aa4f5","updated":"2023-05-23 21:35:41.000000000","message":"Done","commit_id":"402f493ad0d4732e4da2d227e21e351554d58b8f"},{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"21ac675cffb6f2cb9ae04cdc51d7d3d9b609e40f","unresolved":true,"context_lines":[{"line_number":128,"context_line":"            (\"sa_ipv4\", ctypes.c_ubyte * 4),"},{"line_number":129,"context_line":"            # For AF_INET6, ^^^ becomes... flowinfo, I think?"},{"line_number":130,"context_line":"            # Seems to usually be zeroed out"},{"line_number":131,"context_line":"            (\"sa_ipv6\", ctypes.c_ubyte * 16),"},{"line_number":132,"context_line":"        ]"},{"line_number":133,"context_line":""},{"line_number":134,"context_line":"    class ifaddrs(ctypes.Structure):"}],"source_content_type":"text/x-python","patch_set":4,"id":"ce02cbe8_446f4566","line":131,"updated":"2023-05-19 18:11:22.000000000","message":"Note that IPv6 additionally has a scope ID after this field, but we don\u0027t care about it (and in fact strip it out when using netifaces).","commit_id":"402f493ad0d4732e4da2d227e21e351554d58b8f"},{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"801d00054e4048ced2e44271b2461037506e4e78","unresolved":false,"context_lines":[{"line_number":128,"context_line":"            (\"sa_ipv4\", ctypes.c_ubyte * 4),"},{"line_number":129,"context_line":"            # For AF_INET6, ^^^ becomes... flowinfo, I think?"},{"line_number":130,"context_line":"            # Seems to usually be zeroed out"},{"line_number":131,"context_line":"            (\"sa_ipv6\", ctypes.c_ubyte * 16),"},{"line_number":132,"context_line":"        ]"},{"line_number":133,"context_line":""},{"line_number":134,"context_line":"    class ifaddrs(ctypes.Structure):"}],"source_content_type":"text/x-python","patch_set":4,"id":"f91c119e_d0f637a0","line":131,"in_reply_to":"ce02cbe8_446f4566","updated":"2023-05-23 21:35:41.000000000","message":"Ack","commit_id":"402f493ad0d4732e4da2d227e21e351554d58b8f"},{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"21ac675cffb6f2cb9ae04cdc51d7d3d9b609e40f","unresolved":true,"context_lines":[{"line_number":139,"context_line":"        (\"ifa_next\", ctypes.POINTER(ifaddrs)),"},{"line_number":140,"context_line":"        (\"ifa_name\", ctypes.c_char_p),"},{"line_number":141,"context_line":"        (\"ifa_flags\", ctypes.c_int),"},{"line_number":142,"context_line":"        (\"ifa_addr\", ctypes.POINTER(sockaddr)),"},{"line_number":143,"context_line":"        (\"ifa_netmask\", ctypes.POINTER(sockaddr)),"},{"line_number":144,"context_line":"        (\"ifa_broadaddr\", ctypes.POINTER(sockaddr)),"},{"line_number":145,"context_line":"        (\"ifa_data\", ctypes.c_void_p),"}],"source_content_type":"text/x-python","patch_set":4,"id":"fc9d3d4f_cc0e9e69","line":142,"updated":"2023-05-19 18:11:22.000000000","message":"We don\u0027t actually care about anything after this; if we want we could drop `ifa_netmask`, `ifa_broadaddr`, and `ifa_data`.","commit_id":"402f493ad0d4732e4da2d227e21e351554d58b8f"},{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"801d00054e4048ced2e44271b2461037506e4e78","unresolved":false,"context_lines":[{"line_number":139,"context_line":"        (\"ifa_next\", ctypes.POINTER(ifaddrs)),"},{"line_number":140,"context_line":"        (\"ifa_name\", ctypes.c_char_p),"},{"line_number":141,"context_line":"        (\"ifa_flags\", ctypes.c_int),"},{"line_number":142,"context_line":"        (\"ifa_addr\", ctypes.POINTER(sockaddr)),"},{"line_number":143,"context_line":"        (\"ifa_netmask\", ctypes.POINTER(sockaddr)),"},{"line_number":144,"context_line":"        (\"ifa_broadaddr\", ctypes.POINTER(sockaddr)),"},{"line_number":145,"context_line":"        (\"ifa_data\", ctypes.c_void_p),"}],"source_content_type":"text/x-python","patch_set":4,"id":"79d9f6d9_002902c9","line":142,"in_reply_to":"fc9d3d4f_cc0e9e69","updated":"2023-05-23 21:35:41.000000000","message":"Done","commit_id":"402f493ad0d4732e4da2d227e21e351554d58b8f"},{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"02b2c7254e20fe27314b212bc3a5943a6752dfc2","unresolved":true,"context_lines":[{"line_number":113,"context_line":"        else:"},{"line_number":114,"context_line":"            # Assume BSD / OS X"},{"line_number":115,"context_line":"            _fields_ \u003d ["},{"line_number":116,"context_line":"                (\"sin_length\", ctypes.c_uint8),"},{"line_number":117,"context_line":"                (\"sin6_family\", ctypes.c_uint8),"},{"line_number":118,"context_line":"                (\"sin6_port\", ctypes.c_uint16),"},{"line_number":119,"context_line":"                (\"sin6_flowinfo\", ctypes.c_uint32),"}],"source_content_type":"text/x-python","patch_set":7,"id":"fe21e820_d3f0eaf4","line":116,"range":{"start_line":116,"start_character":18,"end_line":116,"end_character":28},"updated":"2023-05-22 22:59:14.000000000","message":"Was copying/pasting -- should maybe be `sin6_length` for consistency\u0027s sake. w/e, this is the only code I expect to ever even *maybe* look at it, and it doesn\u0027t.","commit_id":"4de8516326f92c1b98756afded932fc6984a2c96"},{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"801d00054e4048ced2e44271b2461037506e4e78","unresolved":true,"context_lines":[{"line_number":113,"context_line":"        else:"},{"line_number":114,"context_line":"            # Assume BSD / OS X"},{"line_number":115,"context_line":"            _fields_ \u003d ["},{"line_number":116,"context_line":"                (\"sin_length\", ctypes.c_uint8),"},{"line_number":117,"context_line":"                (\"sin6_family\", ctypes.c_uint8),"},{"line_number":118,"context_line":"                (\"sin6_port\", ctypes.c_uint16),"},{"line_number":119,"context_line":"                (\"sin6_flowinfo\", ctypes.c_uint32),"}],"source_content_type":"text/x-python","patch_set":7,"id":"2761cf1e_3d2b819b","line":116,"range":{"start_line":116,"start_character":18,"end_line":116,"end_character":28},"in_reply_to":"1e9e7a31_7eda4372","updated":"2023-05-23 21:35:41.000000000","message":"So it won\u0027t be in `netifaces` -- that just `#include`s some system headers that have the definitions. It gets a little interesting:\n\n- `getifaddrs` gets you a linked list of `struct ifaddrs`, one per address. The different platforms at least seem to agree on the layout there; see https://www.man7.org/linux/man-pages/man3/getifaddrs.3.html and https://man.freebsd.org/cgi/man.cgi?getifaddrs\n- Each `struct ifaddrs` includes several pointers to `struct sockaddr`s -- these are platform-dependent. See\n- A `struct sockaddr` isn\u0027t terribly useful on its own -- https://www.man7.org/linux/man-pages/man7/socket.7.html has this to say:\n\n\u003e The purpose of this type is purely to allow casting of domain-specific socket address types to a \"generic\" type, so as to avoid compiler warnings about type mismatches in calls to the sockets API.\n\nAlthough to get the actual definition, you might need to go look at some source: https://github.com/torvalds/linux/blob/master/include/linux/socket.h#L34-L40\n\nFreeBSD offers a slightly different definition in https://docs.freebsd.org/en/books/developers-handbook/sockets/#sockets-sockaddr and also calls out\n\n\u003e the _vagueness_ with which the `sa_data` field is declared, just as an array of `14` bytes, with the comment hinting there can be more than `14` of them.\n\n- So the way to actually _use_ a `struct sockaddr` is to take a look at the `sa_family` and use _that_ to figure out the right struct to use. Fortunately, both platforms include that family, even if there isn\u0027t consistency about the size or location in memory.\n\n- Since `whataremyips` only cares about `AF_INET` and `AF_INET6` addresses, we can just consider `struct sockaddr_in` and `struct sockaddr_in6`; see\n  - https://www.man7.org/linux/man-pages/man7/ip.7.html\n  - https://www.man7.org/linux/man-pages/man7/ipv6.7.html\n  - https://cgit.freebsd.org/src/tree/sys/netinet/in.h#n96\n  - https://cgit.freebsd.org/src/tree/sys/netinet6/in6.h#n125\n\nThere\u0027s also some good info gathered at https://man.archlinux.org/man/core/man-pages/sockaddr.3type.en\n\nCome to think of it, I should maybe use `sin_addr`/`sin6_addr` for consistency with upstream sources -- I\u0027d named the fields this earlier when I was considering just having the one (somewhat bastardized) `sockaddr` struct; see patchset 4.\n\nFWIW, I finally decided against that when I considered how the ipv6 address goes out past the guaranteed 14 bytes we\u0027ll have for `sa_data` -- and I wasn\u0027t sure whether the segfault risk was in actually _looking at_ the field when it wasn\u0027t actually an IPv6 address, or if it could trip just by trying to have the python-land combined-`sockaddr` in hand.","commit_id":"4de8516326f92c1b98756afded932fc6984a2c96"},{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"f75cf84355e6c29b35aed8a7b8df109b35a9cae6","unresolved":false,"context_lines":[{"line_number":113,"context_line":"        else:"},{"line_number":114,"context_line":"            # Assume BSD / OS X"},{"line_number":115,"context_line":"            _fields_ \u003d ["},{"line_number":116,"context_line":"                (\"sin_length\", ctypes.c_uint8),"},{"line_number":117,"context_line":"                (\"sin6_family\", ctypes.c_uint8),"},{"line_number":118,"context_line":"                (\"sin6_port\", ctypes.c_uint16),"},{"line_number":119,"context_line":"                (\"sin6_flowinfo\", ctypes.c_uint32),"}],"source_content_type":"text/x-python","patch_set":7,"id":"2420428c_bf0b087e","line":116,"range":{"start_line":116,"start_character":18,"end_line":116,"end_character":28},"in_reply_to":"2761cf1e_3d2b819b","updated":"2023-05-24 07:00:04.000000000","message":"Wow, great response, and yup now I totally get what your doing. And following the links, yup this is my reading of how to do all this.. awesome work Tim!","commit_id":"4de8516326f92c1b98756afded932fc6984a2c96"},{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"64521bf505459947c667a72ca9d072457e1cebf2","unresolved":true,"context_lines":[{"line_number":113,"context_line":"        else:"},{"line_number":114,"context_line":"            # Assume BSD / OS X"},{"line_number":115,"context_line":"            _fields_ \u003d ["},{"line_number":116,"context_line":"                (\"sin_length\", ctypes.c_uint8),"},{"line_number":117,"context_line":"                (\"sin6_family\", ctypes.c_uint8),"},{"line_number":118,"context_line":"                (\"sin6_port\", ctypes.c_uint16),"},{"line_number":119,"context_line":"                (\"sin6_flowinfo\", ctypes.c_uint32),"}],"source_content_type":"text/x-python","patch_set":7,"id":"1e9e7a31_7eda4372","line":116,"range":{"start_line":116,"start_character":18,"end_line":116,"end_character":28},"in_reply_to":"fe21e820_d3f0eaf4","updated":"2023-05-23 07:21:08.000000000","message":"To make it easier for me to be lazy and confirm the moved code any chance you can point me at the netifaces code you\u0027ve got this from.. no stress I can google it I guess, but a link would make lazy matt happy ;)","commit_id":"4de8516326f92c1b98756afded932fc6984a2c96"},{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"f75cf84355e6c29b35aed8a7b8df109b35a9cae6","unresolved":true,"context_lines":[{"line_number":131,"context_line":"        # Use the smaller of the two to start, can cast later"},{"line_number":132,"context_line":"        # when we *know* we\u0027re looking at INET6"},{"line_number":133,"context_line":"        (\"ifa_addr\", ctypes.POINTER(sockaddr_in4)),"},{"line_number":134,"context_line":"        # Don\u0027t care about the rest of the fields"},{"line_number":135,"context_line":"    ]"},{"line_number":136,"context_line":""},{"line_number":137,"context_line":"    def errcheck(result, func, arguments):"}],"source_content_type":"text/x-python","patch_set":8,"id":"fa266d49_4c9e50fa","line":134,"updated":"2023-05-24 07:00:04.000000000","message":"We probably don\u0027t need them in our implementation of getting the ips. But I do wonder if having the netmask available would be useful, even if we don\u0027t use it today:\n\n    (\"ifa_netmask\", ctypes.POINTER(sockaddr_in4)),\n  \nWould also be nice to have in case we ever need it in the future. I can imagine knowing the current netmask \"could\" be useful one day.\n\nBut this is really just a nitpic, this is awesome Tim!","commit_id":"23fa18d3021fb44d8b4dd81890d9c355eed9426f"},{"author":{"_account_id":7233,"name":"Matthew Oliver","email":"matt@oliver.net.au","username":"mattoliverau"},"change_message_id":"f75cf84355e6c29b35aed8a7b8df109b35a9cae6","unresolved":true,"context_lines":[{"line_number":175,"context_line":"            while cur:"},{"line_number":176,"context_line":"                if not cur.contents.ifa_addr:"},{"line_number":177,"context_line":"                    # Not all interfaces will have addresses; move on"},{"line_number":178,"context_line":"                    cur \u003d cur.contents.ifa_next"},{"line_number":179,"context_line":"                    continue"},{"line_number":180,"context_line":"                sa_family \u003d cur.contents.ifa_addr.contents.sin_family"},{"line_number":181,"context_line":"                if sa_family \u003d\u003d socket.AF_INET:"}],"source_content_type":"text/x-python","patch_set":8,"id":"fc53c139_f3bf7d26","line":178,"range":{"start_line":178,"start_character":26,"end_line":178,"end_character":47},"updated":"2023-05-24 07:00:04.000000000","message":"It feels so weird to translate python syntax into C. So this is equiv of cur-\u003eifa_next","commit_id":"23fa18d3021fb44d8b4dd81890d9c355eed9426f"}],"test/unit/common/utils/test_ipaddrs.py":[{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"3bb7df3fd733d93193f7c5fc4a2a73529be6e6be","unresolved":true,"context_lines":[{"line_number":153,"context_line":"                # MAC address will be ignored"},{"line_number":154,"context_line":"                utils_ipaddrs.ifaddrs(None, b\u0027eth0\u0027, 0, ctypes.cast("},{"line_number":155,"context_line":"                    ctypes.pointer(utils_ipaddrs.sockaddr_in6("},{"line_number":156,"context_line":"                        sin6_family\u003dsocket.AF_PACKET,"},{"line_number":157,"context_line":"                        sin6_port\u003d0,"},{"line_number":158,"context_line":"                        sin6_flowinfo\u003d2,"},{"line_number":159,"context_line":"                        sin6_ipv6\u003d("}],"source_content_type":"text/x-python","patch_set":7,"id":"852fe340_4bc6f1bf","line":156,"range":{"start_line":156,"start_character":36,"end_line":156,"end_character":52},"updated":"2023-05-23 16:33:06.000000000","message":"AF_PACKET is not a thing on macos\n\nMaybe use some hard-coded int? The intent seems to be to verify that only AF_INET and AF_INET6 are included in the reported addrs?","commit_id":"4de8516326f92c1b98756afded932fc6984a2c96"},{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"801d00054e4048ced2e44271b2461037506e4e78","unresolved":false,"context_lines":[{"line_number":153,"context_line":"                # MAC address will be ignored"},{"line_number":154,"context_line":"                utils_ipaddrs.ifaddrs(None, b\u0027eth0\u0027, 0, ctypes.cast("},{"line_number":155,"context_line":"                    ctypes.pointer(utils_ipaddrs.sockaddr_in6("},{"line_number":156,"context_line":"                        sin6_family\u003dsocket.AF_PACKET,"},{"line_number":157,"context_line":"                        sin6_port\u003d0,"},{"line_number":158,"context_line":"                        sin6_flowinfo\u003d2,"},{"line_number":159,"context_line":"                        sin6_ipv6\u003d("}],"source_content_type":"text/x-python","patch_set":7,"id":"78105da5_cdeb4c34","line":156,"range":{"start_line":156,"start_character":36,"end_line":156,"end_character":52},"in_reply_to":"852fe340_4bc6f1bf","updated":"2023-05-23 21:35:41.000000000","message":"\u003e The intent seems to be to verify that only AF_INET and AF_INET6 are included in the reported addrs?\n\nYes, that was the idea.\n\n\u003e Maybe use some hard-coded int?\n\nCan do!","commit_id":"4de8516326f92c1b98756afded932fc6984a2c96"}]}
