Add ability to create subint's from Linux
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.
This commit is contained in:
@ -178,9 +178,10 @@ format_nl_object (u8 *s, va_list *args)
|
||||
|
||||
if (rtnl_link_is_vlan (link))
|
||||
{
|
||||
s = format (s, " vlan { id %d proto 0x%04x",
|
||||
rtnl_link_vlan_get_id (link),
|
||||
ntohs (rtnl_link_vlan_get_protocol (link)));
|
||||
s =
|
||||
format (s, " vlan { parent-idx %d id %d proto 0x%04x",
|
||||
rtnl_link_get_link (link), rtnl_link_vlan_get_id (link),
|
||||
ntohs (rtnl_link_vlan_get_protocol (link)));
|
||||
s = format (s, " flags 0x%04x", rtnl_link_vlan_get_flags (link));
|
||||
rtnl_link_vlan_flags2str (rtnl_link_vlan_get_flags (link), buf,
|
||||
sizeof (buf));
|
||||
|
Reference in New Issue
Block a user