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

Update vrf.py #97

Closed
wants to merge 2 commits into from
Closed

Conversation

jhiggins-NZ
Copy link

Fixed variables for ip rule commands.

Was incorrectly referencing vrf_dev_name, instead of vrf_table.
Caused ip rule cmd to fail.

Before:
ip rule add pref 200 oif {{vrf_dev_name}} table {{vrf_dev_name}}

After:
ip rule add pref 200 oif {{vrf_dev_name}} table {{vrf_table}}

Fixed variables for ip rule commands.

Was incorrectly referencing vrf_dev_name, instead of vrf_table.
E.g.

Before:
ip rule add pref 200 oif {{vrf_dev_name}} table {{vrf_dev_name}}

After:
ip rule add pref 200 oif {{vrf_dev_name}} table {{vrf_table}}
@roopa-prabhu
Copy link
Contributor

@jhiggins-NZ thanks for the patch!. Can you pls share your config + iproute2 version ?.

ifupdown2 sets vrf_dev_name = vrf_table_name in auto mode and we populate iproute2 table name map. So, just curious what config you were using and what error are you seeing.

@jhiggins-NZ
Copy link
Author

Hi @roopa-prabhu,

Example config:
auto vrf_test1
iface vrf_test1
vrf-table auto

auto eth1
iface eth1 inet static
address 10.0.0.1/24
vrf vrf_test1

ifupdown2 version:
ifupdown2_1.2.5-1

IP Route 2 verson
4.20.0

Example of the issue:
ifreload -a
error: vrf_test1: cmd '/bin/ip rule add pref 200 oif vrf_test1 table vrf_test1' failed: returned 255 (Error: argument "vrf_test1" is wrong: invalid table ID

Essentially here ip rule is expecting a table ID. Instead the variable references the table name instead :)

Hope this helps.

Cheers,
Jason.

@julienfortin
Copy link
Contributor

Hi @jhiggins-NZ

I tried it on my debian buster and it seems to work. Can I ask you to provide debug log?
ifreload -a -d

What we suspect is that you are missing the rt_table file

[8:10:36] root:~ # cat /etc/iproute2/rt_tables.d/ifupdown2_vrf_map.conf
# This file is autogenerated by ifupdown2.
# It contains the vrf name to table mapping.
# Reserved table range 1001 5000
1001 vrf_test1
[8:10:38] root:~ #

Extract from the man:

table TABLEID

the table to add this route to. TABLEID may be a number or a string from the file /etc/iproute2/rt_tables. If this parameter is omitted, ip assumes the main table, with the exception of local, broadcast and nat routes, which are put into the local table by default.

@jhiggins-NZ
Copy link
Author

Got my hands full for the next week, but will retest after that.

In the meantime, setup is a fresh ubuntu 16.04.5 server install, with Kernel 4.16.
Clone & install iproute2 v4.20, then clone & build ifupdown2.

Then the rest of the test is exactly as above.

@jhiggins-NZ
Copy link
Author

Hi @julienfortin

Looks like you are correct.

info: vrf: syncing table map to /etc/iproute2/rt_tables.d/ifupdown2_vrf_map.conf
info: unable to save iproute2 vrf to table map ([Errno 2] No such file or directory: '/etc/iproute2/rt_tables.d/ifupdown2_vrf_map.conf')

info: cannot find /etc/iproute2/rt_tables.d. pls check if your iproute2 version supports rt_tables.d
info: vrf: dumping iproute2_vrf_map
info: {1001: 'vrf_test'}

/etc/iproute2# ls
bpf_pinning group rt_dsfield rt_realms rt_tables
ematch_map nl_protos rt_protos rt_scopes

Do you know why iproute2 4.20 is missing the file?
I'll do some investigation myself, but thought to ask incase you have seen this before.

Cheers,
Jason.

Change vrf_dev_name to vrf_table for VRF ip rule delete
@julienfortin
Copy link
Contributor

Hello @jhiggins-NZ

On my debian buster VM I have iproute2 4.20 installed and I can see that this directory exists.

[7:28:38] root:~ # ll /etc/iproute2/rt_tables.d
total 8.0K
-rw-r--r-- 1 root root 136 Feb 28 14:48 ifupdown2_vrf_map.conf
-rw-r--r-- 1 root root 144 Jan  7 08:24 README
[7:28:38] root:~ # dpkg -l | grep iproute
ii  iproute2                         4.20.0-2                     amd64        networking and traffic control tools
[7:28:41] root:~ #

Maybe you should purge and reinstall iproute2?

Let me know.

@julienfortin
Copy link
Contributor

Hello @jhiggins-NZ

Did you fix the iproute2 issue?
I'll close this for now but we can continue the discussion.

Thanks,
Julien

@virtualized-human
Copy link

virtualized-human commented Jan 24, 2025

moved to #318

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

Successfully merging this pull request may close these issues.

4 participants