mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-01 10:56:14 +00:00

This patch lets the netlink sockets work per VRF. * The definition of "struct nlsock" is moved into zebra/rib.h. * The previous global variables "netlink" and "netlink_cmd" now become the members of "struct zebra_vrf", and are initialized in zebra_vrf_alloc(). * All relative functions now work for a specific VRF, by adding a new parameter which specifies the working VRF, except those functions in which the VRF ID can be obtained from the interface. * kernel_init(), interface_list() and route_read() are now also working per VRF, and moved from main() to zebra_vrf_enable(). * A new function kernel_terminate() is added to release the netlink sockets. It is called from zebra_vrf_disable(). * Correct VRF ID, instead of the previous VRF_DEFAULT, are now passed to the functions of processing interfaces or route entries. Signed-off-by: Feng Lu <lu.feng@6wind.com> Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Donald Sharp <sharpd@cumulusnetworks.com> Conflicts: lib/memtypes.c zebra/rib.h zebra/rt_netlink.c Conflicts: zebra/if_netlink.c zebra/if_sysctl.c zebra/kernel_null.c zebra/rib.h zebra/rt_netlink.c zebra/rt_netlink.h
65 lines
2.0 KiB
C
65 lines
2.0 KiB
C
/* NULL kernel methods for testing. */
|
|
|
|
#include <zebra.h>
|
|
#include <log.h>
|
|
|
|
#include "zebra/zserv.h"
|
|
#include "zebra/rt.h"
|
|
#include "zebra/redistribute.h"
|
|
#include "zebra/connected.h"
|
|
#include "zebra/rt_netlink.h"
|
|
#include "zebra/rib.h"
|
|
|
|
int kernel_add_ipv4 (struct prefix *a, struct rib *b) { return 0; }
|
|
int kernel_update_ipv4 (struct prefix *a, struct rib *b) { return 0; }
|
|
#ifdef HAVE_SYS_WEAK_ALIAS_PRAGMA
|
|
#pragma weak kernel_delete_ipv4 = kernel_add_ipv4
|
|
#else
|
|
int kernel_delete_ipv4 (struct prefix *a, struct rib *b) { return 0; }
|
|
#endif
|
|
|
|
int kernel_add_ipv6 (struct prefix *a, struct rib *b) { return 0; }
|
|
#ifdef HAVE_SYS_WEAK_ALIAS_PRAGMA
|
|
#pragma weak kernel_delete_ipv6 = kernel_add_ipv6
|
|
#else
|
|
int kernel_delete_ipv6 (struct prefix *a, struct rib *b) { return 0; }
|
|
#endif
|
|
|
|
int kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate,
|
|
unsigned int index, int flags, int table)
|
|
{ return 0; }
|
|
|
|
int kernel_add_route (struct prefix_ipv4 *a, struct in_addr *b, int c, int d)
|
|
{ return 0; }
|
|
|
|
int kernel_address_add_ipv4 (struct interface *a, struct connected *b)
|
|
{
|
|
zlog_debug ("%s", __func__);
|
|
SET_FLAG (b->conf, ZEBRA_IFC_REAL);
|
|
connected_add_ipv4 (a, 0, &b->address->u.prefix4, b->address->prefixlen,
|
|
(b->destination ? &b->destination->u.prefix4 : NULL),
|
|
NULL);
|
|
return 0;
|
|
}
|
|
|
|
int kernel_address_delete_ipv4 (struct interface *a, struct connected *b)
|
|
{
|
|
zlog_debug ("%s", __func__);
|
|
connected_delete_ipv4 (a, 0, &b->address->u.prefix4, b->address->prefixlen,
|
|
(b->destination ? &b->destination->u.prefix4 : NULL));
|
|
return 0;
|
|
}
|
|
|
|
int netlink_neigh_update (int cmd, int ifindex, __u32 addr, char *lla, int llalen)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
void kernel_init (struct zebra_vrf *zvrf) { return; }
|
|
void kernel_terminate (struct zebra_vrf *zvrf) { return; }
|
|
#ifdef HAVE_SYS_WEAK_ALIAS_PRAGMA
|
|
#pragma weak route_read = kernel_init
|
|
#else
|
|
void route_read (struct zebra_vrf *zvrf) { return; }
|
|
#endif
|