This is an automated email from the ASF dual-hosted git repository. bmahler pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
The following commit(s) were added to refs/heads/master by this push: new 82bff25ef [route] Use nl_addr_iszero helper when checking for destination IP network. 82bff25ef is described below commit 82bff25ef26559e36b9bfa26fade96a53a492f79 Author: Jason Zhou <jasonzhou...@gmail.com> AuthorDate: Wed Jun 12 11:11:09 2024 -0400 [route] Use nl_addr_iszero helper when checking for destination IP network. Previously, when grabbing the destination, we would filter out the default address at 0.0.0.0/0 by checking that the destination pointer is pointing at an empty struct. On newer Linux, it seems to be possible that the destination pointer can be pointing at a valid struct that corresponds to 0.0.0.0/0. To ensure that we are able accurately filter out the default route, we switch to the libnl function nl_addr_iszero to determine if the nl_addr struct corresponds to 0.0.0.0/0. We also apply this change to other areas where nl_addr_get_len is used to ensure that non-empty nl_addr with only zeroes are accounted for. Review: https://reviews.apache.org/r/75046/ --- src/linux/routing/diagnosis/diagnosis.cpp | 2 +- src/linux/routing/route.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/linux/routing/diagnosis/diagnosis.cpp b/src/linux/routing/diagnosis/diagnosis.cpp index eed84533c..cd5a31ff7 100644 --- a/src/linux/routing/diagnosis/diagnosis.cpp +++ b/src/linux/routing/diagnosis/diagnosis.cpp @@ -41,7 +41,7 @@ namespace socket { static Option<net::IP> IP(nl_addr* _ip) { - if (_ip != nullptr && nl_addr_get_len(_ip) != 0) { + if (_ip != nullptr && !nl_addr_iszero(_ip)) { if (nl_addr_get_family(_ip) == AF_INET) { struct in_addr* addr = (struct in_addr*)nl_addr_get_binary_addr(_ip); return net::IP(*addr); diff --git a/src/linux/routing/route.cpp b/src/linux/routing/route.cpp index bdf29a9c7..03cefaff9 100644 --- a/src/linux/routing/route.cpp +++ b/src/linux/routing/route.cpp @@ -77,7 +77,7 @@ Try<vector<Rule>> table() // Get the destination IP network if exists. Option<net::IP::Network> destination; struct nl_addr* dst = rtnl_route_get_dst(route); - if (dst != nullptr && nl_addr_get_len(dst) != 0) { + if (dst != nullptr && !nl_addr_iszero(dst)) { struct in_addr* addr = (struct in_addr*) nl_addr_get_binary_addr(dst); Try<net::IP::Network> network = net::IP::Network::create( net::IP(*addr), @@ -96,7 +96,7 @@ Try<vector<Rule>> table() Option<net::IP> gateway; struct rtnl_nexthop* hop = rtnl_route_nexthop_n(route, 0); struct nl_addr* gw = rtnl_route_nh_get_gateway(CHECK_NOTNULL(hop)); - if (gw != nullptr && nl_addr_get_len(gw) != 0) { + if (gw != nullptr && !nl_addr_iszero(gw)) { struct in_addr* addr = (struct in_addr*) nl_addr_get_binary_addr(gw); gateway = net::IP(*addr); }