DPDK / grout

grout # a graph router based on DPDK
BSD 3-Clause "New" or "Revised" License
6 stars 3 forks source link

ip: add function to get preferred iface address #55

Closed rjarry closed 1 month ago

rjarry commented 1 month ago

In the datapath, we often need to get the correct IP address on an interface in order to reply or transmit a packet. Rename ip4_addr_get_default to ip4_addr_get_preferred which takes an additional destination IP address as argument. It will return the first address assigned to the interface that is in the same subnet.

If no address is found in that subnet, use the first address by default.

Rename struct iface_addresses to struct hoplist, the structure will be reused in order to support multiple next hops associated with a route prefix.

In a future commit, the next hops will need to be reordered so that the first address is the best default.