Hey all,

I recently stumbled across a bug in bgpd where when announcing connected routes 
(i.e. network $AF connected) for IPv6 routes over IPv4 TCP BGP connections, 
bgpd was announcing the IPv6 routes with a next hop of ::1, the localhost 
address.

I traced this down in the bgpd code to get_alternate_addr in session.c 
incorrectly calling sa_cmp.

sa_cmp in util.c compares two sockaddr structures and true (non-zero) if they 
are equal and false (zero) if they are different. However, get_alternate_addr 
treats the sa_cmp call as if it behaved like memcmp (zero if equal, non-zero if 
different). This leads to get_alternate_addr behaving incorrectly.

The fix is to change the comparison (sa_cmp(sa, match->ifa_addr) == 0) from == 
to !=.

After implementing the change and running the patched version locally, I have 
confirmed that it properly selects and reports nexthops when the route AF is 
different from the BGP TCP connection AF.

Thanks,

Asa Yeamans

Reply via email to