Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle edge cases in interface and routing config #1136

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

czeumer
Copy link

@czeumer czeumer commented Oct 4, 2023

The pull requests fixes two issues with very special configurations:

  • if more than one default route with different metrics is specified, the one with the highest metric is chosen
  • if an interface has more than one address and the first routable address is not the first address entry a non routable address is returned.

Here an example of such a fringe configuration:

interface Config (excerpt):

10: vlan_1@nic: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 01:23:45:cb:2a:b6 brd ff:ff:ff:ff:ff:ff
    inet 169.254.95.54/16 metric 2048 brd 169.254.255.255 scope link vlan_1
       valid_lft forever preferred_lft forever
    inet 10.1.42.7/24 brd 10.1.42.255 scope global vlan_1
       valid_lft forever preferred_lft forever
11: vlan_2@nic: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 01:23:45:cb:2a:b6 brd ff:ff:ff:ff:ff:ff
    inet 169.254.26.132/16 metric 2048 brd 169.254.255.255 scope link vlan_2
       valid_lft forever preferred_lft forever
    inet 10.32.1.133/25 brd 10.32.1.255 scope global vlan_2
       valid_lft forever preferred_lft forever

routes (excerpt):

default via 10.1.42.1 dev vlan_transfer proto static metric 40 
default via 192.168.155.1 dev eno5 proto dhcp src 192.168.155.12 metric 100 

With this configuration, the source address for the interfaces 10 and 11 will return the link local address of the interface.
The default route will return 192.168.155.1 which is only the second in the list.

Both issues are addressed in this pull request.

Cheers,
Carsten

@google-cla
Copy link

google-cla bot commented Oct 4, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant