Add newlink/delink processing.

- Can up/down a link.
- Can set MAC on a link, if it's a phy.
- Can set MTU on a link.
- Can delete link (including phy).

Because link state and mtu changes tend to go around in circles (from
netlink -> vpp; and then with lcp-sync on, as well from vpp -> netlink)
when we consume a batch of netlink messages, we'll temporarily turn off
lcp-sync if it's enabled.

TODO (in the next commit), the whole nine yards of creating interfaces
in VPP based on NEWLINK vlans that come in. Conceptualy not too
difficult: if NEWLINK doesn't have a LIP associated with it, but it's a
VLAN, and the parent of the VLAN is a link which _does_ have a LIP, then
we can create the subint in VPP in the correct way.
This commit is contained in:
Pim van Pelt
2021-08-24 18:11:51 +02:00
parent 6d2ce1cd83
commit a3a5f68926
4 changed files with 185 additions and 4 deletions

View File

@ -211,6 +211,10 @@ lcp_nl_dispatch (struct nl_object *obj, void *arg)
return lcp_nl_addr_add ((struct rtnl_addr *) obj);
case RTM_DELADDR:
return lcp_nl_addr_del ((struct rtnl_addr *) obj);
case RTM_NEWLINK:
return lcp_nl_link_add ((struct rtnl_link *) obj, arg);
case RTM_DELLINK:
return lcp_nl_link_del ((struct rtnl_link *) obj);
default:
NL_WARN ("dispatch: ignored %U", format_nl_object, obj);
break;
@ -226,6 +230,15 @@ lcp_nl_process_msgs (void)
f64 start = vlib_time_now (vlib_get_main ());
u64 usecs = 0;
/* To avoid loops where VPP->LCP sync fights with LCP->VPP
* sync, we turn off the former if it's enabled, while we consume
* the netlink messages in this function, and put it back at the
* end of the function.
*/
lcp_main_t *lcpm = &lcp_main;
u8 old_lcp_sync = lcpm->lcp_sync;
lcpm->lcp_sync = 0;
/* process a batch of messages. break if we hit our batch_size
* count limit or batch_delay_ms time limit.
*
@ -264,6 +277,8 @@ lcp_nl_process_msgs (void)
"process_msgs: Processed %u messages in %llu usecs, %u left in queue",
n_msgs, usecs, vec_len (nm->nl_ns.nl_msg_queue));
lcpm->lcp_sync = old_lcp_sync;
return n_msgs;
}