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)
Tue, Apr 16, 3:16 PM
Unknown Object (File)
Fri, Mar 29, 12:04 AM
Unknown Object (File)
Feb 29 2024, 11:29 PM
Unknown Object (File)
Jan 28 2024, 10:18 PM
Unknown Object (File)
Dec 31 2023, 2:06 AM
Unknown Object (File)
Dec 22 2023, 8:44 PM
Unknown Object (File)
Dec 20 2023, 1:21 AM
Unknown Object (File)
Nov 13 2023, 10:27 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.