bisdn / basebox

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

properly handle route lookups when no default route #397

Closed KanjiMonster closed 1 year ago

KanjiMonster commented 1 year ago

When there is no route for a host, the kernel may respond with an error, which we treat as fatal and crash. Fix this by accepting the error as normal.

Description

When there is no default route, the kernel may respond with -ENETUNREACH or -EHOSTUNREACH instead of a route. libnl then translates this error as -NLE_FAILURE, so treat -NLE_FAILURE as no route found and just return a nullptr.

Motivation and Context

We should not crash when failing lookups because the management interface is (temporarily) down.

How Has This Been Tested?

Ran a pipeline on as4630-54pe, which succeeded.

KanjiMonster commented 1 year ago

When there is no default route, the kernel may respond with -ENETUNREACH or -EHOSTUNREACH instead of a route. libnl then translates this error as -NLE_FAILURE, so treat -NLE_FAILURE as no route found and just return a nullptr.

This can be seen by using libnl-3-cli's nl-route-get for an unrachable ip address (e.g. when the management interface is down).