mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-12 07:48:25 +00:00
zebra: ipv6 operations stick to namespace
All ipv6 operations stick to namespace. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
9a76375f39
commit
5895d33f40
@ -805,21 +805,26 @@ void if_nbr_ipv6ll_to_ipv4ll_neigh_update(struct interface *ifp,
|
|||||||
char buf[16] = "169.254.0.1";
|
char buf[16] = "169.254.0.1";
|
||||||
struct in_addr ipv4_ll;
|
struct in_addr ipv4_ll;
|
||||||
char mac[6];
|
char mac[6];
|
||||||
|
ns_id_t ns_id;
|
||||||
|
|
||||||
inet_pton(AF_INET, buf, &ipv4_ll);
|
inet_pton(AF_INET, buf, &ipv4_ll);
|
||||||
|
|
||||||
ipv6_ll_address_to_mac(address, (u_char *)mac);
|
ipv6_ll_address_to_mac(address, (u_char *)mac);
|
||||||
|
|
||||||
|
if (!vrf_is_backend_netns())
|
||||||
|
ns_id = NS_DEFAULT;
|
||||||
|
else
|
||||||
|
ns_id = (ns_id_t)(ifp->vrf_id);
|
||||||
/*
|
/*
|
||||||
* Remove existed arp record for the interface as netlink
|
* Remove existed arp record for the interface as netlink
|
||||||
* protocol does not have update message types
|
* protocol does not have update message types
|
||||||
*
|
*
|
||||||
* supported message types are RTM_NEWNEIGH and RTM_DELNEIGH
|
* supported message types are RTM_NEWNEIGH and RTM_DELNEIGH
|
||||||
*/
|
*/
|
||||||
kernel_neigh_update (0, ifp->ifindex, ipv4_ll.s_addr, mac, 6);
|
kernel_neigh_update(0, ifp->ifindex, ipv4_ll.s_addr, mac, 6, ns_id);
|
||||||
|
|
||||||
/* Add arp record */
|
/* Add arp record */
|
||||||
kernel_neigh_update (add, ifp->ifindex, ipv4_ll.s_addr, mac, 6);
|
kernel_neigh_update(add, ifp->ifindex, ipv4_ll.s_addr, mac, 6, ns_id);
|
||||||
zvrf->neigh_updates++;
|
zvrf->neigh_updates++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,8 @@ extern int kernel_address_add_ipv4(struct interface *, struct connected *);
|
|||||||
extern int kernel_address_delete_ipv4(struct interface *, struct connected *);
|
extern int kernel_address_delete_ipv4(struct interface *, struct connected *);
|
||||||
extern int kernel_address_add_ipv6 (struct interface *, struct connected *);
|
extern int kernel_address_add_ipv6 (struct interface *, struct connected *);
|
||||||
extern int kernel_address_delete_ipv6 (struct interface *, struct connected *);
|
extern int kernel_address_delete_ipv6 (struct interface *, struct connected *);
|
||||||
extern int kernel_neigh_update(int, int, uint32_t, char *, int);
|
extern int kernel_neigh_update(int cmd, int ifindex, uint32_t addr,
|
||||||
|
char *lla, int llalen, ns_id_t ns_id);
|
||||||
extern int kernel_interface_set_master(struct interface *master,
|
extern int kernel_interface_set_master(struct interface *master,
|
||||||
struct interface *slave);
|
struct interface *slave);
|
||||||
|
|
||||||
|
@ -1282,7 +1282,7 @@ static void _netlink_mpls_debug(int cmd, u_int32_t label, const char *routedesc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int netlink_neigh_update(int cmd, int ifindex, uint32_t addr, char *lla,
|
static int netlink_neigh_update(int cmd, int ifindex, uint32_t addr, char *lla,
|
||||||
int llalen)
|
int llalen, ns_id_t ns_id)
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
struct nlmsghdr n;
|
struct nlmsghdr n;
|
||||||
@ -1290,7 +1290,7 @@ static int netlink_neigh_update(int cmd, int ifindex, uint32_t addr, char *lla,
|
|||||||
char buf[256];
|
char buf[256];
|
||||||
} req;
|
} req;
|
||||||
|
|
||||||
struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
|
struct zebra_ns *zns = zebra_ns_lookup(ns_id);
|
||||||
|
|
||||||
memset(&req.n, 0, sizeof(req.n));
|
memset(&req.n, 0, sizeof(req.n));
|
||||||
memset(&req.ndm, 0, sizeof(req.ndm));
|
memset(&req.ndm, 0, sizeof(req.ndm));
|
||||||
@ -1638,8 +1638,12 @@ int kernel_get_ipmr_sg_stats(struct zebra_vrf *zvrf, void *in)
|
|||||||
} req;
|
} req;
|
||||||
|
|
||||||
mroute = mr;
|
mroute = mr;
|
||||||
struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
|
struct zebra_ns *zns;
|
||||||
|
|
||||||
|
if (!vrf_is_backend_netns())
|
||||||
|
zns = zebra_ns_lookup(NS_DEFAULT);
|
||||||
|
else
|
||||||
|
zns = (struct zebra_ns *)ns_info_lookup(zvrf->vrf->vrf_id);
|
||||||
memset(&req.n, 0, sizeof(req.n));
|
memset(&req.n, 0, sizeof(req.n));
|
||||||
memset(&req.ndm, 0, sizeof(req.ndm));
|
memset(&req.ndm, 0, sizeof(req.ndm));
|
||||||
|
|
||||||
@ -1712,10 +1716,10 @@ void kernel_route_rib(struct route_node *rn, struct prefix *p,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int kernel_neigh_update(int add, int ifindex, uint32_t addr, char *lla,
|
int kernel_neigh_update(int add, int ifindex, uint32_t addr, char *lla,
|
||||||
int llalen)
|
int llalen, ns_id_t ns_id)
|
||||||
{
|
{
|
||||||
return netlink_neigh_update(add ? RTM_NEWNEIGH : RTM_DELNEIGH, ifindex,
|
return netlink_neigh_update(add ? RTM_NEWNEIGH : RTM_DELNEIGH, ifindex,
|
||||||
addr, lla, llalen);
|
addr, lla, llalen, ns_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1725,7 +1729,7 @@ int kernel_neigh_update(int add, int ifindex, uint32_t addr, char *lla,
|
|||||||
static int netlink_vxlan_flood_list_update(struct interface *ifp,
|
static int netlink_vxlan_flood_list_update(struct interface *ifp,
|
||||||
struct in_addr *vtep_ip, int cmd)
|
struct in_addr *vtep_ip, int cmd)
|
||||||
{
|
{
|
||||||
struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
|
struct zebra_ns *zns;
|
||||||
struct {
|
struct {
|
||||||
struct nlmsghdr n;
|
struct nlmsghdr n;
|
||||||
struct ndmsg ndm;
|
struct ndmsg ndm;
|
||||||
@ -1733,6 +1737,10 @@ static int netlink_vxlan_flood_list_update(struct interface *ifp,
|
|||||||
} req;
|
} req;
|
||||||
u_char dst_mac[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
|
u_char dst_mac[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
|
||||||
|
|
||||||
|
if (!vrf_is_backend_netns())
|
||||||
|
zns = zebra_ns_lookup(NS_DEFAULT);
|
||||||
|
else
|
||||||
|
zns = (struct zebra_ns *)ns_info_lookup(ifp->vrf_id);
|
||||||
memset(&req.n, 0, sizeof(req.n));
|
memset(&req.n, 0, sizeof(req.n));
|
||||||
memset(&req.ndm, 0, sizeof(req.ndm));
|
memset(&req.ndm, 0, sizeof(req.ndm));
|
||||||
|
|
||||||
@ -1788,7 +1796,7 @@ int kernel_del_vtep(vni_t vni, struct interface *ifp, struct in_addr *vtep_ip)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int netlink_macfdb_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
|
static int netlink_macfdb_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
|
||||||
int len)
|
int len, ns_id_t ns_id)
|
||||||
{
|
{
|
||||||
struct ndmsg *ndm;
|
struct ndmsg *ndm;
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
@ -1811,7 +1819,7 @@ static int netlink_macfdb_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* The interface should exist. */
|
/* The interface should exist. */
|
||||||
ifp = if_lookup_by_index_per_ns(zebra_ns_lookup(NS_DEFAULT),
|
ifp = if_lookup_by_index_per_ns(zebra_ns_lookup(ns_id),
|
||||||
ndm->ndm_ifindex);
|
ndm->ndm_ifindex);
|
||||||
if (!ifp || !ifp->info)
|
if (!ifp || !ifp->info)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1942,7 +1950,7 @@ static int netlink_macfdb_table(struct sockaddr_nl *snl, struct nlmsghdr *h,
|
|||||||
if (ndm->ndm_family != AF_BRIDGE)
|
if (ndm->ndm_family != AF_BRIDGE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return netlink_macfdb_change(snl, h, len);
|
return netlink_macfdb_change(snl, h, len, ns_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Request for MAC FDB information from the kernel */
|
/* Request for MAC FDB information from the kernel */
|
||||||
@ -2024,7 +2032,7 @@ static int netlink_macfdb_update(struct interface *ifp, vlanid_t vid,
|
|||||||
struct ethaddr *mac, struct in_addr vtep_ip,
|
struct ethaddr *mac, struct in_addr vtep_ip,
|
||||||
int local, int cmd, u_char sticky)
|
int local, int cmd, u_char sticky)
|
||||||
{
|
{
|
||||||
struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
|
struct zebra_ns *zns;
|
||||||
struct {
|
struct {
|
||||||
struct nlmsghdr n;
|
struct nlmsghdr n;
|
||||||
struct ndmsg ndm;
|
struct ndmsg ndm;
|
||||||
@ -2039,6 +2047,10 @@ static int netlink_macfdb_update(struct interface *ifp, vlanid_t vid,
|
|||||||
char vid_buf[20];
|
char vid_buf[20];
|
||||||
char dst_buf[30];
|
char dst_buf[30];
|
||||||
|
|
||||||
|
if (!vrf_is_backend_netns())
|
||||||
|
zns = zebra_ns_lookup(NS_DEFAULT);
|
||||||
|
else
|
||||||
|
zns = (struct zebra_ns *)ns_info_lookup(ifp->vrf_id);
|
||||||
zif = ifp->info;
|
zif = ifp->info;
|
||||||
if ((br_if = zif->brslave_info.br_if) == NULL) {
|
if ((br_if = zif->brslave_info.br_if) == NULL) {
|
||||||
zlog_warn("MAC %s on IF %s(%u) - no mapping to bridge",
|
zlog_warn("MAC %s on IF %s(%u) - no mapping to bridge",
|
||||||
@ -2098,7 +2110,7 @@ static int netlink_macfdb_update(struct interface *ifp, vlanid_t vid,
|
|||||||
| NUD_DELAY)
|
| NUD_DELAY)
|
||||||
|
|
||||||
static int netlink_ipneigh_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
|
static int netlink_ipneigh_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
|
||||||
int len)
|
int len, ns_id_t ns_id)
|
||||||
{
|
{
|
||||||
struct ndmsg *ndm;
|
struct ndmsg *ndm;
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
@ -2119,7 +2131,7 @@ static int netlink_ipneigh_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* The interface should exist. */
|
/* The interface should exist. */
|
||||||
ifp = if_lookup_by_index_per_ns(zebra_ns_lookup(NS_DEFAULT),
|
ifp = if_lookup_by_index_per_ns(zebra_ns_lookup(ns_id),
|
||||||
ndm->ndm_ifindex);
|
ndm->ndm_ifindex);
|
||||||
if (!ifp || !ifp->info)
|
if (!ifp || !ifp->info)
|
||||||
return 0;
|
return 0;
|
||||||
@ -2141,7 +2153,7 @@ static int netlink_ipneigh_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
|
|||||||
* itself
|
* itself
|
||||||
*/
|
*/
|
||||||
if (IS_ZEBRA_IF_VLAN(ifp)) {
|
if (IS_ZEBRA_IF_VLAN(ifp)) {
|
||||||
link_if = if_lookup_by_index_per_ns(zebra_ns_lookup(NS_DEFAULT),
|
link_if = if_lookup_by_index_per_ns(zebra_ns_lookup(ns_id),
|
||||||
zif->link_ifindex);
|
zif->link_ifindex);
|
||||||
if (!link_if)
|
if (!link_if)
|
||||||
return 0;
|
return 0;
|
||||||
@ -2319,13 +2331,13 @@ int netlink_neigh_change(struct sockaddr_nl *snl, struct nlmsghdr *h,
|
|||||||
/* Is this a notification for the MAC FDB or IP neighbor table? */
|
/* Is this a notification for the MAC FDB or IP neighbor table? */
|
||||||
ndm = NLMSG_DATA(h);
|
ndm = NLMSG_DATA(h);
|
||||||
if (ndm->ndm_family == AF_BRIDGE)
|
if (ndm->ndm_family == AF_BRIDGE)
|
||||||
return netlink_macfdb_change(snl, h, len);
|
return netlink_macfdb_change(snl, h, len, ns_id);
|
||||||
|
|
||||||
if (ndm->ndm_type != RTN_UNICAST)
|
if (ndm->ndm_type != RTN_UNICAST)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (ndm->ndm_family == AF_INET || ndm->ndm_family == AF_INET6)
|
if (ndm->ndm_family == AF_INET || ndm->ndm_family == AF_INET6)
|
||||||
return netlink_ipneigh_change(snl, h, len);
|
return netlink_ipneigh_change(snl, h, len, ns_id);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2340,10 +2352,14 @@ static int netlink_neigh_update2(struct interface *ifp, struct ipaddr *ip,
|
|||||||
} req;
|
} req;
|
||||||
int ipa_len;
|
int ipa_len;
|
||||||
|
|
||||||
struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
|
struct zebra_ns *zns;
|
||||||
char buf[INET6_ADDRSTRLEN];
|
char buf[INET6_ADDRSTRLEN];
|
||||||
char buf2[ETHER_ADDR_STRLEN];
|
char buf2[ETHER_ADDR_STRLEN];
|
||||||
|
|
||||||
|
if (!vrf_is_backend_netns())
|
||||||
|
zns = zebra_ns_lookup(NS_DEFAULT);
|
||||||
|
else
|
||||||
|
zns = (struct zebra_ns *)ns_info_lookup(ifp->vrf_id);
|
||||||
memset(&req.n, 0, sizeof(req.n));
|
memset(&req.n, 0, sizeof(req.n));
|
||||||
memset(&req.ndm, 0, sizeof(req.ndm));
|
memset(&req.ndm, 0, sizeof(req.ndm));
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ void kernel_route_rib(struct route_node *rn, struct prefix *p,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int kernel_neigh_update(int add, int ifindex, uint32_t addr, char *lla,
|
int kernel_neigh_update(int add, int ifindex, uint32_t addr, char *lla,
|
||||||
int llalen)
|
int llalen, ns_id_t ns_id)
|
||||||
{
|
{
|
||||||
/* TODO */
|
/* TODO */
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user