Sync IPv4 and IPv6 addresses from VPP to LCP

There are three ways in which IP addresses will want to be copied
from VPP into the companion Linux devices:

1) set interface ip address ... adds an IPv4 or IPv6 address
  - this is handled by lcp_itf_ip[46]_add_del_interface_addr() which
    is a callback installed in lcp_itf_pair_init()
2) set interface ip address del ... removes them
  - also handled by lcp_itf_ip[46]_add_del_interface_addr() but
    curiously there is no upstream vnet_netlink_del_ip[46]_addr() so
    I wrote them inline here - I will try to get them upstreamed, as
    they appear to be obvious companions in vnet/device/netlink.h
3) Upon LIP creation, it could be that there are L3 addresses already
   on the VPP interface. If so, set them with lcp_itf_set_interface_addr()

This means that now, at any time a new LIP is created, its state from
VPP is fully copied over (MTU, Link state, IPv4/IPv6 addresses)!

At runtime, new addresses can be set/removed as well.
This commit is contained in:
Pim van Pelt
2021-08-13 16:50:32 +02:00
parent 39bfa1615f
commit f7e1bb951d
4 changed files with 265 additions and 4 deletions

View File

@ -18,6 +18,8 @@
#include <vnet/dpo/dpo.h>
#include <vnet/adj/adj.h>
#include <vnet/ip/ip_types.h>
#include <vnet/udp/udp.h>
#include <vnet/tcp/tcp.h>
#include <plugins/lcpng/lcpng.h>
@ -170,6 +172,21 @@ void lcp_itf_pair_register_vft (lcp_itf_pair_vft_t *lcp_itf_vft);
/* Set TAP and Linux host link state */
void lcp_itf_set_link_state (const lcp_itf_pair_t *lip, u8 state);
/* Set any VPP L3 addresses on Linux host device */
void lcp_itf_set_interface_addr (const lcp_itf_pair_t *lip);
/* Sync IPv4 and IPv6 address from VPP to Linux device */
void lcp_itf_ip4_add_del_interface_addr (ip4_main_t *im, uword opaque,
u32 sw_if_index,
ip4_address_t *address,
u32 address_length,
u32 if_address_index, u32 is_del);
void lcp_itf_ip6_add_del_interface_addr (ip6_main_t *im, uword opaque,
u32 sw_if_index,
ip6_address_t *address,
u32 address_length,
u32 if_address_index, u32 is_del);
/*
* fd.io coding-style-patch-verification: ON
*