diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-02-23 03:10:16 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-02-23 22:47:11 +0900 |
commit | 0e9d129c1603a0768adcb4e6b8218c16a07ac82f (patch) | |
tree | 0b036c2567a2f753893b98903d0f542d09e3587a /src/network/networkd-nexthop.c | |
parent | e64e052e17b2f3a7a19c3bcbc3b326088f388f3a (diff) | |
download | systemd-0e9d129c1603a0768adcb4e6b8218c16a07ac82f.tar.gz |
network: nexthop: read protocol in received netlink message
Preparation of later commits.
Diffstat (limited to 'src/network/networkd-nexthop.c')
-rw-r--r-- | src/network/networkd-nexthop.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/network/networkd-nexthop.c b/src/network/networkd-nexthop.c index 0b598823f6..29ed5b5ef9 100644 --- a/src/network/networkd-nexthop.c +++ b/src/network/networkd-nexthop.c @@ -102,6 +102,7 @@ static int nexthop_new_static(Network *network, const char *filename, unsigned s static void nexthop_hash_func(const NextHop *nexthop, struct siphash *state) { assert(nexthop); + siphash24_compress(&nexthop->protocol, sizeof(nexthop->protocol), state); siphash24_compress(&nexthop->id, sizeof(nexthop->id), state); siphash24_compress(&nexthop->blackhole, sizeof(nexthop->blackhole), state); siphash24_compress(&nexthop->family, sizeof(nexthop->family), state); @@ -121,6 +122,10 @@ static void nexthop_hash_func(const NextHop *nexthop, struct siphash *state) { static int nexthop_compare_func(const NextHop *a, const NextHop *b) { int r; + r = CMP(a->protocol, b->protocol); + if (r != 0) + return r; + r = CMP(a->id, b->id); if (r != 0) return r; @@ -152,6 +157,7 @@ static void nexthop_copy(NextHop *dest, const NextHop *src) { /* This only copies entries used in the above hash and compare functions. */ + dest->protocol = src->protocol; dest->id = src->id; dest->blackhole = src->blackhole; dest->family = src->family; @@ -530,6 +536,12 @@ int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message, } else if (!IN_SET(tmp->family, AF_INET, AF_INET6)) return log_link_debug(link, "rtnl: received nexthop message with invalid family %d, ignoring.", tmp->family); + r = sd_rtnl_message_nexthop_get_protocol(message, &tmp->protocol); + if (r < 0) { + log_link_warning_errno(link, r, "rtnl: could not get nexthop protocol, ignoring: %m"); + return 0; + } + r = netlink_message_read_in_addr_union(message, NHA_GATEWAY, tmp->family, &tmp->gw); if (r < 0 && r != -ENODATA) { log_link_warning_errno(link, r, "rtnl: could not get NHA_GATEWAY attribute, ignoring: %m"); |