bisdn / basebox

A tiny OpenFlow controller for OF-DPA switches.
Mozilla Public License 2.0
45 stars 9 forks source link

cnetlink: get_link_by_ifindex: fix af family check #384

Closed KanjiMonster closed 2 years ago

KanjiMonster commented 2 years ago

We need to check the family of the passed cache object, not the argument. Else we read random garbage from the stack, and sometimes it might or might not be equal to AF_INET6.

Fixes get_link_by_ifindex sometimes failing to find a link object, which may even crash baseboxd:

Jul 07 23:31:22 accton-as4610 baseboxd[1121]: I0707 23:31:22.864306  1129 cnetlink.cc:679] is_bridge_interface: vlan ok
Jul 07 23:31:22 accton-as4610 baseboxd[1121]: baseboxd: ../git/src/netlink/cnetlink.cc:660: bool basebox::cnetlink::is_bridge_interface(rtnl_link*) const: Assertion `l' failed.
Jul 07 23:31:22 accton-as4610 systemd[1]: Created slice system-systemd\x2dcoredump.slice.
Jul 07 23:31:22 accton-as4610 systemd[1]: Started Process Core Dump (PID 1741/UID 0).

Fixes: 50fe194b8f79 ("cnetlink: fetch bridge object with ifindex and address family") Signed-off-by: Jonas Gorski jonas.gorski@bisdn.de

Description

Motivation and Context

How Has This Been Tested?