mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-11-05 18:05:46 +00:00
Reduce or eliminate use of global zebra_ns structs in a couple of netlink/kernel code paths, so that those paths can potentially be made asynch eventually. Slide netlink_talk_info into place to remove dependency on core zebra structs; add accessors for dplane context block Start init of route context from zebra core re and rn structs; start queueing and event handling for incoming route updates. Expose netlink apis that don't rely on zebra core structs; add parallel route-update code path using the dplane ctx; simplest possible event loop to process queued route' updates. Signed-off-by: Mark Stapp <mjs@voltanet.io>
142 lines
3.5 KiB
C
142 lines
3.5 KiB
C
/*
|
|
* Zebra NS header
|
|
* Copyright (C) 2016 Cumulus Networks, Inc.
|
|
* Donald Sharp
|
|
*
|
|
* This file is part of Quagga.
|
|
*
|
|
* Quagga is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
* later version.
|
|
*
|
|
* Quagga is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; see the file COPYING; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
#if !defined(__ZEBRA_NS_H__)
|
|
#define __ZEBRA_NS_H__
|
|
|
|
#include <lib/ns.h>
|
|
#include <lib/vrf.h>
|
|
|
|
#include "zebra/rib.h"
|
|
#include "zebra/zebra_vrf.h"
|
|
|
|
#ifdef HAVE_NETLINK
|
|
/* Socket interface to kernel */
|
|
struct nlsock {
|
|
int sock;
|
|
int seq;
|
|
struct sockaddr_nl snl;
|
|
char name[64];
|
|
};
|
|
#endif
|
|
|
|
struct zebra_ns_table {
|
|
RB_ENTRY(zebra_ns_table) zebra_ns_table_entry;
|
|
|
|
uint32_t tableid;
|
|
afi_t afi;
|
|
ns_id_t ns_id;
|
|
|
|
struct route_table *table;
|
|
};
|
|
RB_HEAD(zebra_ns_table_head, zebra_ns_table);
|
|
RB_PROTOTYPE(zebra_ns_table_head, zebra_ns_table, zebra_ns_table_entry,
|
|
zebra_ns_table_entry_compare)
|
|
|
|
struct zebra_ns {
|
|
/* net-ns name. */
|
|
char name[VRF_NAMSIZ];
|
|
|
|
/* Identifier. */
|
|
ns_id_t ns_id;
|
|
|
|
#ifdef HAVE_NETLINK
|
|
struct nlsock netlink; /* kernel messages */
|
|
struct nlsock netlink_cmd; /* command channel */
|
|
struct thread *t_netlink;
|
|
#endif
|
|
|
|
struct route_table *if_table;
|
|
|
|
/* L3-VNI hash table (for EVPN). Only in default instance */
|
|
struct hash *l3vni_table;
|
|
|
|
#if defined(HAVE_RTADV)
|
|
struct rtadv rtadv;
|
|
#endif /* HAVE_RTADV */
|
|
|
|
struct zebra_ns_table_head ns_tables;
|
|
|
|
struct hash *rules_hash;
|
|
|
|
struct hash *ipset_hash;
|
|
|
|
struct hash *ipset_entry_hash;
|
|
|
|
struct hash *iptable_hash;
|
|
|
|
/* Back pointer */
|
|
struct ns *ns;
|
|
};
|
|
|
|
/* Key netlink info from zebra ns, passed from the zebra main context
|
|
* to the dataplane/kernel context (which might be in a different pthread).
|
|
*/
|
|
struct zebra_ns_info {
|
|
ns_id_t ns_id;
|
|
|
|
#if defined(HAVE_NETLINK)
|
|
struct nlsock nls;
|
|
uint32_t nl_cmd_pid;
|
|
bool is_cmd;
|
|
#endif
|
|
};
|
|
|
|
/* Utility to fill in zns info from main zns struct */
|
|
static inline void zebra_ns_info_from_ns(struct zebra_ns_info *zns_info,
|
|
const struct zebra_ns *zns,
|
|
bool is_cmd)
|
|
{
|
|
zns_info->ns_id = zns->ns_id;
|
|
|
|
#if defined(HAVE_NETLINK)
|
|
/* Need to know whether we're using the 'command' netlink socket,
|
|
* and need to know its port-id to handle some test/filtering
|
|
* cases.
|
|
*/
|
|
zns_info->is_cmd = is_cmd;
|
|
zns_info->nl_cmd_pid = zns->netlink_cmd.snl.nl_pid;
|
|
if (is_cmd) {
|
|
zns_info->nls = zns->netlink_cmd;
|
|
} else {
|
|
zns_info->nls = zns->netlink;
|
|
}
|
|
#endif /* NETLINK */
|
|
}
|
|
|
|
struct zebra_ns *zebra_ns_lookup(ns_id_t ns_id);
|
|
|
|
int zebra_ns_init(void);
|
|
int zebra_ns_enable(ns_id_t ns_id, void **info);
|
|
int zebra_ns_disabled(struct ns *ns);
|
|
int zebra_ns_disable(ns_id_t ns_id, void **info);
|
|
|
|
extern struct route_table *zebra_ns_find_table(struct zebra_ns *zns,
|
|
uint32_t tableid, afi_t afi);
|
|
extern struct route_table *zebra_ns_get_table(struct zebra_ns *zns,
|
|
struct zebra_vrf *zvrf,
|
|
uint32_t tableid, afi_t afi);
|
|
int zebra_ns_config_write(struct vty *vty, struct ns *ns);
|
|
|
|
unsigned long zebra_ns_score_proto(uint8_t proto, unsigned short instance);
|
|
void zebra_ns_sweep_route(void);
|
|
#endif
|