Using the earlier placeholder hint in lcp_nl_link_add(), I know that I've gotten a NEWLINK request but the linux ifindex doesn't have a LIP. This could be because the interface is entirely foreign to VPP, for example somebody created a dummy interface or a VLAN subint on one: ip link add dum0 type dummy ip link add link dum0 name dum0.10 type vlan id 10 Or, I'm actually trying to create a VLAN subint, like these: ip link add link e0 name e0.1234 type vlan id 1234 ip link add link e0.1234 name e0.1235 type vlan id 1000 ip link add link e0 name e0.1236 type vlan id 2345 proto 802.1ad ip link add link e0.1236 name e0.1237 type vlan id 1000 None of these NEWLINK callbacks, represented by vif (linux interface id) will have a corresponding LIP. So, I try to create one by calling lcp_nl_link_add_vlan(). Here, I lookup the parent index ('dum0' or 'e0' in the first examples), the former of which also doesn't have a LIP, so I bail. If it does, I still have two choices: 1) the LIP is a phy (ie TenGigabitEthernet3/0/0) and this is a regular tagged interface; or 2) the LIP is itself a subint (ie TenGigabitEthernet3/0/0.1234) and what I'm asking for is a QinQ or QinAD sub-interface. So I look up as well the phy LIP. We now have all the ingredients I need to create the VPP sub-interfaces with the correct inner-dot1q and outer dot1q or dot1ad. Of course, I don't really know what subinterface ID to use. It's appealing to "just" use the vlan, but that's not helpful if the outer tag and the inner tag are the same. So I write a helper function vnet_sw_interface_get_available_subid() whose job it is to return an unused subid for the phy -- starting from 1. I then create the phy sub-interface and the tap sub-interface, tying them together into a new LIP. During these interface creations, I want to make sure that if lcp-auto-subint is on, we disable that. I don't want VPP racing to create LIPs for the sub-ints right now. Before I return (either in error state or upon success), I put back the lcp-auto-subint to what it was before. If I manage to create the LIP, huzzah. I return it to the caller so it can continue setting link/mac/mtu etc.
130 lines
5.3 KiB
Markdown
130 lines
5.3 KiB
Markdown
# Introduction
|
|
|
|
This plugin is a *temporary!* copy of VPP's src/plugins/linux-cp/ plugin,
|
|
originally by the following authors:
|
|
* Signed-off-by: Neale Ranns <nranns@cisco.com>
|
|
* Signed-off-by: Matthew Smith <mgsmith@netgate.com>
|
|
* Signed-off-by: Jon Loeliger <jdl@netgate.com>
|
|
* Signed-off-by: Pim van Pelt <pim@ipng.nl>
|
|
* Signed-off-by: Neale Ranns <neale@graphiant.com>
|
|
|
|
See previous work:
|
|
* [interface mirroring](https://gerrit.fd.io/r/c/vpp/+/30759)
|
|
* [netlink listener](https://gerrit.fd.io/r/c/vpp/+/31122)
|
|
|
|
My work is intended to be re-submitted for review as a cleanup/rewrite of the
|
|
existing Linux CP interface mirror and netlink syncer.
|
|
|
|
Follow along on [my blog](https://ipng.ch/s/articles/) for my findings while
|
|
I work towards a completed plugin that can copy VPP configuration into Linux
|
|
interfaces, and copy Linux configuration changes into VPP (ie. a fully
|
|
bidirectional pipe between Linux and VPP).
|
|
|
|
When the code is complete, this plugin should be able to work seemlessly with
|
|
a higher level controlplane like [FRR](https://frrouting.org/) or
|
|
[Bird](https://bird.network.cz/), for example as a BGP/OSPF speaking ISP router.
|
|
|
|
## WARNING!!
|
|
|
|
The only reason that this code is here, is so that I can make some progress
|
|
iterating on the Linux CP plugin, and share my findings with some interested
|
|
folks. The goal is NOT to use this plugin anywhere other than a bench. I
|
|
intend to contribute the plugin back upstream as soon as it's peer reviewed!
|
|
|
|
***Pull Requests and Issues will be immediately closed without warning***
|
|
|
|
VPP's code lives at [fd.io](https://gerrit.fd.io/r/c/vpp), and this copy is
|
|
shared only for convenience purposes.
|
|
|
|
## Functionality
|
|
|
|
The following functionality is supported by the plugin. The VPP->Linux column
|
|
shows changes in VPP that are copied into the Linux environment; Linux->VPP
|
|
column shows changes in LInux that are copied into VPP.
|
|
|
|
| Function | VPP -> Linux | Linux -> VPP |
|
|
| -------------- | ------------- | -------------|
|
|
| Up/Down Link | ✅ | ✅ |
|
|
| Change MTU | ✅ | ✅ |
|
|
| Change MAC | ❌ 1) | ✅ |
|
|
| Add/Del IP4/IP6 Address | ✅ | ✅ |
|
|
| Route | ❌ 2) | 🟠 |
|
|
| Add/Del Tunnel | ❌ | ❌ |
|
|
| Add/Del Phy | ✅ | 🟠 |
|
|
| Add/Del .1q | ✅ | ✅ |
|
|
| Add/Del .1ad | ✅ | ✅ |
|
|
| Add/Del QinQ | ✅ | ✅ |
|
|
| Add/Del QinAD | ✅ | ✅ |
|
|
| Add/Del BondEthernet | ✅ | 🟠 |
|
|
|
|
Legend: ✅=supported; 🟠=maybe; ❌=infeasible.
|
|
|
|
1) There is no callback or macro to register an interest in MAC address changes in VPP.
|
|
2) There is no callback or macro to register an interest in FIB changes in VPP.
|
|
|
|
## Building
|
|
|
|
First, ensure that you can build and run 'vanilla' VPP by using the
|
|
[instructions](https://wiki.fd.io/view/VPP/Pulling,_Building,_Running,_Hacking_and_Pushing_VPP_Code).
|
|
Then check out this plugin out-of-tree and symlink it in.
|
|
|
|
```
|
|
mkdir ~/src
|
|
cd ~/src
|
|
git clone https://github.com/pimvanpelt/lcpng.git
|
|
ln -s ~/src/vpp/src/plugins/lcpng ~src/lcpng
|
|
```
|
|
|
|
## Running
|
|
|
|
Ensure this plugin is enabled and the original `linux-cp` plugin is disabled,
|
|
that logging goes to stderr (in the debug variant of VPP), and that the features
|
|
are dis/enabled, by providing the following `startup.conf`:
|
|
```
|
|
plugins {
|
|
path ~/src/vpp/build-root/install-vpp_debug-native/vpp/lib/vpp_plugins
|
|
plugin lcpng_if_plugin.so { enable }
|
|
plugin lcpng_nl_plugin.so { enable }
|
|
plugin linux_cp_plugin.so { disable }
|
|
}
|
|
|
|
logging {
|
|
default-log-level info
|
|
default-syslog-log-level crit
|
|
## Set per-class configuration
|
|
class linux-cp/if { rate-limit 10000 level debug syslog-level debug }
|
|
class linux-cp/nl { rate-limit 10000 level debug syslog-level debug }
|
|
}
|
|
|
|
lcpng {
|
|
default netns dataplane
|
|
lcp-sync
|
|
lcp-auto-subint
|
|
}
|
|
```
|
|
|
|
Then, simply `make build` and `make run` VPP which will load the plugin.
|
|
```
|
|
im@hippo:~/src/vpp$ make run
|
|
snort [debug ]: initialized
|
|
snort [debug ]: snort listener /run/vpp/snort.sock
|
|
linux-cp/if [debug ]: interface_add: [1] sw TenGigabitEthernet3/0/0 is_sub 0 lcp-auto-subint 1
|
|
linux-cp/if [debug ]: mtu_change: sw TenGigabitEthernet3/0/0 0
|
|
linux-cp/if [debug ]: interface_add: [2] sw TenGigabitEthernet3/0/1 is_sub 0 lcp-auto-subint 1
|
|
linux-cp/if [debug ]: mtu_change: sw TenGigabitEthernet3/0/1 0
|
|
linux-cp/if [debug ]: interface_add: [3] sw TenGigabitEthernet3/0/2 is_sub 0 lcp-auto-subint 1
|
|
linux-cp/if [debug ]: mtu_change: sw TenGigabitEthernet3/0/2 0
|
|
linux-cp/if [debug ]: interface_add: [4] sw TenGigabitEthernet3/0/3 is_sub 0 lcp-auto-subint 1
|
|
linux-cp/if [debug ]: mtu_change: sw TenGigabitEthernet3/0/3 0
|
|
linux-cp/if [debug ]: interface_add: [5] sw TwentyFiveGigabitEthernete/0/0 is_sub 0 lcp-auto-subint 1
|
|
linux-cp/if [debug ]: mtu_change: sw TwentyFiveGigabitEthernete/0/0 0
|
|
linux-cp/if [debug ]: interface_add: [6] sw TwentyFiveGigabitEthernete/0/1 is_sub 0 lcp-auto-subint 1
|
|
linux-cp/if [debug ]: mtu_change: sw TwentyFiveGigabitEthernete/0/1 0
|
|
_______ _ _ _____ ___
|
|
__/ __/ _ \ (_)__ | | / / _ \/ _ \
|
|
_/ _// // / / / _ \ | |/ / ___/ ___/
|
|
/_/ /____(_)_/\___/ |___/_/ /_/
|
|
|
|
DBGvpp#
|
|
```
|