Page MenuHomeFreeBSD

Don't iterate over the ifnet addr list in ip_output()
ClosedPublic

Authored by rstone on Jul 20 2016, 11:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 5 2024, 2:05 PM
Unknown Object (File)
Oct 5 2024, 6:56 AM
Unknown Object (File)
Oct 5 2024, 5:40 AM
Unknown Object (File)
Oct 4 2024, 3:59 AM
Unknown Object (File)
Oct 4 2024, 12:20 AM
Unknown Object (File)
Oct 3 2024, 10:55 PM
Unknown Object (File)
Sep 29 2024, 4:56 AM
Unknown Object (File)
Sep 20 2024, 8:58 AM
Subscribers

Details

Summary

For almost every packet that is transmitted through ip_output(),
a call to in_broadcast() was made to decide if the destination
IP was a broadcast address. in_broadcast() iterates over the
ifnet's address to find a source IP matching the subnet of the
destination IP, and then checks if the IP is a broadcast in that
subnet.

This is completely redundant as we have already performed the
route lookup, so the source IP is already known. Just use that
address to directly check whether the destination IP is a
broadcast address or not.

Test Plan

Used ping, traceroute and a custom UDP program to send broadcast packets, and used dtrace to ensure that in_ifaddr_broadcast() was returning the right result.

Used traceroute -r to send packets on an SO_DONTROUTE socket and confirmed that in_ifaddr_broadcast() returned the right result and that a broadcast or unicast MAC address was used appropriately.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

rstone retitled this revision from to Don't iterate over the ifnet addr list in ip_output().
rstone edited the test plan for this revision. (Show Details)
rstone updated this object.
This revision was automatically updated to reflect the committed changes.