bisdn / basebox

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

do not log netlink messages for loopback devices #306

Closed akoepsel closed 3 years ago

akoepsel commented 3 years ago

Signed-off-by: Andreas Koepsel andreas.koepsel@bisdn.de

Description

Swapped code blocks on lines 69-71 and 73-76 in src/netlink/netlink-utils.cc to avoid an exception caused by a NULL (string) pointer when the set of initial netlink messages referring to the loopback device is received and baseboxd's verbosity level causes the VLOG stream to call function rtnl_link_get_family(link).

Motivation and Context

How Has This Been Tested?

KanjiMonster commented 3 years ago

I don't think not logging is the right solution.

Maybe we can have a helper function something like

std::string_view safe_string_view(const char *str)
{
  if (str == nullptr)
    return std::string_view("(null)");
  else
    return std::string_view(str);
}

and then use this everywhere where we might have a null pointer? This would replicate printf's behavior when passing NULL to a %s.

KanjiMonster commented 3 years ago

And then squash all the issues in one (or two) commits.

rubensfig commented 3 years ago

I have changed the target branch to next, to prepare for the merges.

jklare commented 3 years ago

is this still being worked on?