2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Distribute list functions
|
|
|
|
* Copyright (C) 1998, 1999 Kunihiro Ishiguro
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
|
|
|
|
#include "hash.h"
|
|
|
|
#include "if.h"
|
|
|
|
#include "filter.h"
|
|
|
|
#include "command.h"
|
|
|
|
#include "distribute.h"
|
|
|
|
#include "memory.h"
|
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_CTX, "Distribute ctx");
|
2015-05-29 05:48:31 +02:00
|
|
|
DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE, "Distribute list");
|
|
|
|
DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_IFNAME, "Dist-list ifname");
|
|
|
|
DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_NAME, "Dist-list name");
|
|
|
|
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
static struct distribute *distribute_new(void)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2008-08-18 23:13:29 +02:00
|
|
|
return XCALLOC(MTYPE_DISTRIBUTE, sizeof(struct distribute));
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Free distribute object. */
|
|
|
|
static void distribute_free(struct distribute *dist)
|
|
|
|
{
|
2016-09-22 23:11:04 +02:00
|
|
|
int i = 0;
|
|
|
|
|
2019-02-25 21:18:13 +01:00
|
|
|
XFREE(MTYPE_DISTRIBUTE_IFNAME, dist->ifname);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-02-25 21:18:13 +01:00
|
|
|
for (i = 0; i < DISTRIBUTE_MAX; i++) {
|
|
|
|
XFREE(MTYPE_DISTRIBUTE_NAME, dist->list[i]);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-02-25 21:18:13 +01:00
|
|
|
for (i = 0; i < DISTRIBUTE_MAX; i++) {
|
|
|
|
XFREE(MTYPE_DISTRIBUTE_NAME, dist->prefix[i]);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
XFREE(MTYPE_DISTRIBUTE, dist);
|
|
|
|
}
|
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
static void distribute_free_if_empty(struct distribute_ctx *ctx,
|
|
|
|
struct distribute *dist)
|
2016-09-22 23:11:04 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < DISTRIBUTE_MAX; i++)
|
|
|
|
if (dist->list[i] != NULL || dist->prefix[i] != NULL)
|
|
|
|
return;
|
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
hash_release(ctx->disthash, dist);
|
2016-09-22 23:11:04 +02:00
|
|
|
distribute_free(dist);
|
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Lookup interface's distribute list. */
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
struct distribute *distribute_lookup(struct distribute_ctx *ctx,
|
|
|
|
const char *ifname)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct distribute key;
|
|
|
|
struct distribute *dist;
|
|
|
|
|
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-10 13:56:56 +02:00
|
|
|
/* temporary reference */
|
2015-11-22 01:47:32 +01:00
|
|
|
key.ifname = (ifname) ? XSTRDUP(MTYPE_DISTRIBUTE_IFNAME, ifname) : NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
dist = hash_lookup(ctx->disthash, &key);
|
2015-11-22 01:47:32 +01:00
|
|
|
|
2019-02-25 21:18:13 +01:00
|
|
|
XFREE(MTYPE_DISTRIBUTE_IFNAME, key.ifname);
|
2015-05-20 03:04:26 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return dist;
|
|
|
|
}
|
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
void distribute_list_add_hook(struct distribute_ctx *ctx,
|
|
|
|
void (*func)(struct distribute_ctx *ctx,
|
|
|
|
struct distribute *))
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
ctx->distribute_add_hook = func;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
void distribute_list_delete_hook(struct distribute_ctx *ctx,
|
|
|
|
void (*func)(struct distribute_ctx *ctx,
|
|
|
|
struct distribute *))
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
ctx->distribute_delete_hook = func;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *distribute_hash_alloc(struct distribute *arg)
|
|
|
|
{
|
|
|
|
struct distribute *dist;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
dist = distribute_new();
|
|
|
|
if (arg->ifname)
|
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-10 13:56:56 +02:00
|
|
|
dist->ifname = XSTRDUP(MTYPE_DISTRIBUTE_IFNAME, arg->ifname);
|
2002-12-13 21:15:29 +01:00
|
|
|
else
|
|
|
|
dist->ifname = NULL;
|
|
|
|
return dist;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make new distribute list and push into hash. */
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
static struct distribute *distribute_get(struct distribute_ctx *ctx,
|
|
|
|
const char *ifname)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct distribute key;
|
2015-05-20 03:04:26 +02:00
|
|
|
struct distribute *ret;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-10 13:56:56 +02:00
|
|
|
/* temporary reference */
|
2015-11-22 01:47:32 +01:00
|
|
|
key.ifname = (ifname) ? XSTRDUP(MTYPE_DISTRIBUTE_IFNAME, ifname) : NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
ret = hash_get(ctx->disthash, &key,
|
2015-05-20 03:04:26 +02:00
|
|
|
(void *(*)(void *))distribute_hash_alloc);
|
|
|
|
|
2019-02-25 21:18:13 +01:00
|
|
|
XFREE(MTYPE_DISTRIBUTE_IFNAME, key.ifname);
|
2015-11-22 01:47:32 +01:00
|
|
|
|
2015-05-20 03:04:26 +02:00
|
|
|
return ret;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2019-05-14 22:19:07 +02:00
|
|
|
static unsigned int distribute_hash_make(const void *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2010-08-27 23:11:14 +02:00
|
|
|
const struct distribute *dist = arg;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2010-08-27 23:11:14 +02:00
|
|
|
return dist->ifname ? string_hash_make(dist->ifname) : 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If two distribute-list have same value then return 1 else return
|
|
|
|
0. This function is used by hash package. */
|
2018-10-17 21:27:12 +02:00
|
|
|
static bool distribute_cmp(const struct distribute *dist1,
|
2008-08-14 17:25:25 +02:00
|
|
|
const struct distribute *dist2)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
if (dist1->ifname && dist2->ifname)
|
|
|
|
if (strcmp(dist1->ifname, dist2->ifname) == 0)
|
2018-10-17 21:27:12 +02:00
|
|
|
return true;
|
2002-12-13 21:15:29 +01:00
|
|
|
if (!dist1->ifname && !dist2->ifname)
|
2018-10-17 21:27:12 +02:00
|
|
|
return true;
|
|
|
|
return false;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Set access-list name to the distribute list. */
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
static void distribute_list_set(struct distribute_ctx *ctx,
|
|
|
|
const char *ifname, enum distribute_type type,
|
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-10 13:56:56 +02:00
|
|
|
const char *alist_name)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct distribute *dist;
|
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
dist = distribute_get(ctx, ifname);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-02-25 21:18:13 +01:00
|
|
|
XFREE(MTYPE_DISTRIBUTE_NAME, dist->list[type]);
|
2016-09-22 23:11:04 +02:00
|
|
|
dist->list[type] = XSTRDUP(MTYPE_DISTRIBUTE_NAME, alist_name);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Apply this distribute-list to the interface. */
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
(ctx->distribute_add_hook)(ctx, dist);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Unset distribute-list. If matched distribute-list exist then
|
|
|
|
return 1. */
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
static int distribute_list_unset(struct distribute_ctx *ctx,
|
|
|
|
const char *ifname,
|
|
|
|
enum distribute_type type,
|
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-10 13:56:56 +02:00
|
|
|
const char *alist_name)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct distribute *dist;
|
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
dist = distribute_lookup(ctx, ifname);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (!dist)
|
|
|
|
return 0;
|
|
|
|
|
2016-09-22 23:11:04 +02:00
|
|
|
if (!dist->list[type])
|
2002-12-13 21:15:29 +01:00
|
|
|
return 0;
|
2016-09-22 23:11:04 +02:00
|
|
|
if (strcmp(dist->list[type], alist_name) != 0)
|
2002-12-13 21:15:29 +01:00
|
|
|
return 0;
|
|
|
|
|
2016-09-22 23:11:04 +02:00
|
|
|
XFREE(MTYPE_DISTRIBUTE_NAME, dist->list[type]);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Apply this distribute-list to the interface. */
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
(ctx->distribute_delete_hook)(ctx, dist);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2016-09-22 23:11:04 +02:00
|
|
|
/* If all dist are NULL, then free distribute list. */
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
distribute_free_if_empty(ctx, dist);
|
2002-12-13 21:15:29 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set access-list name to the distribute list. */
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
static void distribute_list_prefix_set(struct distribute_ctx *ctx,
|
|
|
|
const char *ifname,
|
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-10 13:56:56 +02:00
|
|
|
enum distribute_type type,
|
|
|
|
const char *plist_name)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct distribute *dist;
|
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
dist = distribute_get(ctx, ifname);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-02-25 21:18:13 +01:00
|
|
|
XFREE(MTYPE_DISTRIBUTE_NAME, dist->prefix[type]);
|
2016-09-22 23:11:04 +02:00
|
|
|
dist->prefix[type] = XSTRDUP(MTYPE_DISTRIBUTE_NAME, plist_name);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Apply this distribute-list to the interface. */
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
(ctx->distribute_add_hook)(ctx, dist);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Unset distribute-list. If matched distribute-list exist then
|
|
|
|
return 1. */
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
static int distribute_list_prefix_unset(struct distribute_ctx *ctx,
|
|
|
|
const char *ifname,
|
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-10 13:56:56 +02:00
|
|
|
enum distribute_type type,
|
|
|
|
const char *plist_name)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct distribute *dist;
|
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
dist = distribute_lookup(ctx, ifname);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (!dist)
|
|
|
|
return 0;
|
|
|
|
|
2016-09-22 23:11:04 +02:00
|
|
|
if (!dist->prefix[type])
|
2002-12-13 21:15:29 +01:00
|
|
|
return 0;
|
2016-09-22 23:11:04 +02:00
|
|
|
if (strcmp(dist->prefix[type], plist_name) != 0)
|
2002-12-13 21:15:29 +01:00
|
|
|
return 0;
|
|
|
|
|
2016-09-22 23:11:04 +02:00
|
|
|
XFREE(MTYPE_DISTRIBUTE_NAME, dist->prefix[type]);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Apply this distribute-list to the interface. */
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
(ctx->distribute_delete_hook)(ctx, dist);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2016-09-22 23:11:04 +02:00
|
|
|
/* If all dist are NULL, then free distribute list. */
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
distribute_free_if_empty(ctx, dist);
|
2002-12-13 21:15:29 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-02-08 15:54:31 +01:00
|
|
|
static enum distribute_type distribute_direction(const char *dir, bool v4)
|
|
|
|
{
|
|
|
|
if (dir[0] == 'i') {
|
|
|
|
if (v4)
|
|
|
|
return DISTRIBUTE_V4_IN;
|
|
|
|
else
|
|
|
|
return DISTRIBUTE_V6_IN;
|
|
|
|
} else if (dir[0] == 'o') {
|
|
|
|
if (v4)
|
|
|
|
return DISTRIBUTE_V4_OUT;
|
|
|
|
else
|
|
|
|
return DISTRIBUTE_V6_OUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(!"Expecting in or out only, fix your code");
|
|
|
|
|
|
|
|
__builtin_unreachable();
|
|
|
|
}
|
|
|
|
|
2024-01-22 02:15:38 +01:00
|
|
|
int distribute_list_parser(struct distribute_ctx *ctx, bool prefix, bool v4,
|
|
|
|
const char *dir, const char *list, const char *ifname)
|
2021-02-08 15:54:31 +01:00
|
|
|
{
|
|
|
|
enum distribute_type type = distribute_direction(dir, v4);
|
2024-01-22 02:15:38 +01:00
|
|
|
|
2021-02-08 15:54:31 +01:00
|
|
|
void (*distfn)(struct distribute_ctx *, const char *,
|
|
|
|
enum distribute_type, const char *) =
|
|
|
|
prefix ? &distribute_list_prefix_set : &distribute_list_set;
|
|
|
|
|
|
|
|
distfn(ctx, ifname, type, list);
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2024-01-22 02:15:38 +01:00
|
|
|
|
|
|
|
int distribute_list_no_parser(struct distribute_ctx *ctx, struct vty *vty,
|
|
|
|
bool prefix, bool v4, const char *dir,
|
|
|
|
const char *list, const char *ifname)
|
2021-02-08 15:54:31 +01:00
|
|
|
{
|
|
|
|
enum distribute_type type = distribute_direction(dir, v4);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
int (*distfn)(struct distribute_ctx *, const char *,
|
|
|
|
enum distribute_type, const char *) =
|
|
|
|
prefix ? &distribute_list_prefix_unset : &distribute_list_unset;
|
|
|
|
|
|
|
|
|
|
|
|
ret = distfn(ctx, ifname, type, list);
|
|
|
|
if (!ret) {
|
2024-01-21 14:12:39 +01:00
|
|
|
if (vty)
|
|
|
|
vty_out(vty, "distribute list doesn't exist\n");
|
2021-02-08 15:54:31 +01:00
|
|
|
return CMD_WARNING_CONFIG_FAILED;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-22 23:11:07 +02:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-22 23:11:04 +02:00
|
|
|
static int distribute_print(struct vty *vty, char *tab[], int is_prefix,
|
|
|
|
enum distribute_type type, int has_print)
|
|
|
|
{
|
|
|
|
if (tab[type]) {
|
|
|
|
vty_out(vty, "%s %s%s", has_print ? "," : "",
|
|
|
|
is_prefix ? "(prefix-list) " : "", tab[type]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return has_print;
|
|
|
|
}
|
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
int config_show_distribute(struct vty *vty, struct distribute_ctx *dist_ctxt)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-10-05 23:01:23 +02:00
|
|
|
unsigned int i;
|
2016-09-22 23:11:04 +02:00
|
|
|
int has_print = 0;
|
2019-02-19 16:46:52 +01:00
|
|
|
struct hash_bucket *mp;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct distribute *dist;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Output filter configuration. */
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
dist = distribute_lookup(dist_ctxt, NULL);
|
2002-12-13 21:15:29 +01:00
|
|
|
vty_out(vty, " Outgoing update filter list for all interface is");
|
2016-09-22 23:11:04 +02:00
|
|
|
has_print = 0;
|
|
|
|
if (dist) {
|
|
|
|
has_print = distribute_print(vty, dist->list, 0,
|
2016-09-22 23:11:07 +02:00
|
|
|
DISTRIBUTE_V4_OUT, has_print);
|
2016-09-22 23:11:04 +02:00
|
|
|
has_print = distribute_print(vty, dist->prefix, 1,
|
2016-09-22 23:11:07 +02:00
|
|
|
DISTRIBUTE_V4_OUT, has_print);
|
|
|
|
has_print = distribute_print(vty, dist->list, 0,
|
|
|
|
DISTRIBUTE_V6_OUT, has_print);
|
|
|
|
has_print = distribute_print(vty, dist->prefix, 1,
|
|
|
|
DISTRIBUTE_V6_OUT, has_print);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2016-09-22 23:11:04 +02:00
|
|
|
if (has_print)
|
2017-07-13 19:04:25 +02:00
|
|
|
vty_out(vty, "\n");
|
2002-12-13 21:15:29 +01:00
|
|
|
else
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty, " not set\n");
|
2017-07-17 14:03:14 +02:00
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
for (i = 0; i < dist_ctxt->disthash->size; i++)
|
|
|
|
for (mp = dist_ctxt->disthash->index[i]; mp; mp = mp->next) {
|
2002-12-13 21:15:29 +01:00
|
|
|
dist = mp->data;
|
|
|
|
if (dist->ifname) {
|
|
|
|
vty_out(vty, " %s filtered by",
|
|
|
|
dist->ifname);
|
2016-09-22 23:11:04 +02:00
|
|
|
has_print = 0;
|
|
|
|
has_print = distribute_print(vty, dist->list, 0,
|
2016-09-22 23:11:07 +02:00
|
|
|
DISTRIBUTE_V4_OUT,
|
|
|
|
has_print);
|
2016-09-22 23:11:04 +02:00
|
|
|
has_print = distribute_print(
|
|
|
|
vty, dist->prefix, 1, DISTRIBUTE_V4_OUT,
|
2016-09-22 23:11:07 +02:00
|
|
|
has_print);
|
|
|
|
has_print = distribute_print(vty, dist->list, 0,
|
|
|
|
DISTRIBUTE_V6_OUT,
|
|
|
|
has_print);
|
|
|
|
has_print = distribute_print(
|
|
|
|
vty, dist->prefix, 1, DISTRIBUTE_V6_OUT,
|
|
|
|
has_print);
|
2016-09-22 23:11:04 +02:00
|
|
|
if (has_print)
|
2017-07-13 19:04:25 +02:00
|
|
|
vty_out(vty, "\n");
|
2016-09-22 23:11:04 +02:00
|
|
|
else
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty, " nothing\n");
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Input filter configuration. */
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
dist = distribute_lookup(dist_ctxt, NULL);
|
2002-12-13 21:15:29 +01:00
|
|
|
vty_out(vty, " Incoming update filter list for all interface is");
|
2016-09-22 23:11:04 +02:00
|
|
|
has_print = 0;
|
|
|
|
if (dist) {
|
|
|
|
has_print = distribute_print(vty, dist->list, 0,
|
2016-09-22 23:11:07 +02:00
|
|
|
DISTRIBUTE_V4_IN, has_print);
|
|
|
|
has_print = distribute_print(vty, dist->prefix, 1,
|
|
|
|
DISTRIBUTE_V4_IN, has_print);
|
|
|
|
has_print = distribute_print(vty, dist->list, 0,
|
|
|
|
DISTRIBUTE_V6_IN, has_print);
|
2016-09-22 23:11:04 +02:00
|
|
|
has_print = distribute_print(vty, dist->prefix, 1,
|
2016-09-22 23:11:07 +02:00
|
|
|
DISTRIBUTE_V6_IN, has_print);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2016-09-22 23:11:04 +02:00
|
|
|
if (has_print)
|
2017-07-13 19:04:25 +02:00
|
|
|
vty_out(vty, "\n");
|
2002-12-13 21:15:29 +01:00
|
|
|
else
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty, " not set\n");
|
2017-07-17 14:03:14 +02:00
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
for (i = 0; i < dist_ctxt->disthash->size; i++)
|
|
|
|
for (mp = dist_ctxt->disthash->index[i]; mp; mp = mp->next) {
|
2002-12-13 21:15:29 +01:00
|
|
|
dist = mp->data;
|
|
|
|
if (dist->ifname) {
|
|
|
|
vty_out(vty, " %s filtered by",
|
|
|
|
dist->ifname);
|
2016-09-22 23:11:04 +02:00
|
|
|
has_print = 0;
|
|
|
|
has_print = distribute_print(vty, dist->list, 0,
|
2016-09-22 23:11:07 +02:00
|
|
|
DISTRIBUTE_V4_IN,
|
|
|
|
has_print);
|
|
|
|
has_print = distribute_print(
|
|
|
|
vty, dist->prefix, 1, DISTRIBUTE_V4_IN,
|
|
|
|
has_print);
|
|
|
|
has_print = distribute_print(vty, dist->list, 0,
|
|
|
|
DISTRIBUTE_V6_IN,
|
|
|
|
has_print);
|
2016-09-22 23:11:04 +02:00
|
|
|
has_print = distribute_print(
|
|
|
|
vty, dist->prefix, 1, DISTRIBUTE_V6_IN,
|
2016-09-22 23:11:07 +02:00
|
|
|
has_print);
|
2016-09-22 23:11:04 +02:00
|
|
|
if (has_print)
|
2017-07-13 19:04:25 +02:00
|
|
|
vty_out(vty, "\n");
|
2016-09-22 23:11:04 +02:00
|
|
|
else
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty, " nothing\n");
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Configuration write function. */
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
int config_write_distribute(struct vty *vty,
|
|
|
|
struct distribute_ctx *dist_ctxt)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-10-05 23:01:23 +02:00
|
|
|
unsigned int i;
|
2016-09-22 23:11:04 +02:00
|
|
|
int j;
|
2016-09-22 23:11:07 +02:00
|
|
|
int output, v6;
|
2019-02-19 16:46:52 +01:00
|
|
|
struct hash_bucket *mp;
|
2002-12-13 21:15:29 +01:00
|
|
|
int write = 0;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
for (i = 0; i < dist_ctxt->disthash->size; i++)
|
|
|
|
for (mp = dist_ctxt->disthash->index[i]; mp; mp = mp->next) {
|
2002-12-13 21:15:29 +01:00
|
|
|
struct distribute *dist;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
dist = mp->data;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-22 23:11:04 +02:00
|
|
|
for (j = 0; j < DISTRIBUTE_MAX; j++)
|
|
|
|
if (dist->list[j]) {
|
2016-09-22 23:11:07 +02:00
|
|
|
output = j == DISTRIBUTE_V4_OUT
|
|
|
|
|| j == DISTRIBUTE_V6_OUT;
|
|
|
|
v6 = j == DISTRIBUTE_V6_IN
|
|
|
|
|| j == DISTRIBUTE_V6_OUT;
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty,
|
|
|
|
" %sdistribute-list %s %s %s\n",
|
2016-09-22 23:11:07 +02:00
|
|
|
v6 ? "ipv6 " : "",
|
2016-09-22 23:11:04 +02:00
|
|
|
dist->list[j],
|
|
|
|
output ? "out" : "in",
|
2017-06-21 05:10:57 +02:00
|
|
|
dist->ifname ? dist->ifname
|
|
|
|
: "");
|
2002-12-13 21:15:29 +01:00
|
|
|
write++;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-22 23:11:04 +02:00
|
|
|
for (j = 0; j < DISTRIBUTE_MAX; j++)
|
|
|
|
if (dist->prefix[j]) {
|
2016-09-22 23:11:07 +02:00
|
|
|
output = j == DISTRIBUTE_V4_OUT
|
|
|
|
|| j == DISTRIBUTE_V6_OUT;
|
|
|
|
v6 = j == DISTRIBUTE_V6_IN
|
|
|
|
|| j == DISTRIBUTE_V6_OUT;
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty,
|
|
|
|
" %sdistribute-list prefix %s %s %s\n",
|
2016-09-22 23:11:07 +02:00
|
|
|
v6 ? "ipv6 " : "",
|
2016-09-22 23:11:04 +02:00
|
|
|
dist->prefix[j],
|
|
|
|
output ? "out" : "in",
|
2017-06-21 05:10:57 +02:00
|
|
|
dist->ifname ? dist->ifname
|
|
|
|
: "");
|
2002-12-13 21:15:29 +01:00
|
|
|
write++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return write;
|
|
|
|
}
|
|
|
|
|
2024-01-21 14:12:39 +01:00
|
|
|
/* ---------- */
|
|
|
|
/* Northbound */
|
|
|
|
/* ---------- */
|
|
|
|
|
|
|
|
int group_distribute_list_create_helper(
|
|
|
|
struct nb_cb_create_args *args, struct distribute_ctx *ctx)
|
|
|
|
{
|
2024-01-22 02:15:38 +01:00
|
|
|
nb_running_set_entry(args->dnode, ctx);
|
2024-01-21 14:12:39 +01:00
|
|
|
return NB_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XPath: /frr-ripd:ripd/instance/distribute-lists/distribute-list/{in,out}/{access,prefix}-list
|
|
|
|
*/
|
|
|
|
|
2024-08-10 00:32:55 +02:00
|
|
|
static int distribute_list_leaf_update(const struct lyd_node *dnode,
|
|
|
|
int ip_version, bool no);
|
|
|
|
|
2024-01-21 14:12:39 +01:00
|
|
|
int group_distribute_list_destroy(struct nb_cb_destroy_args *args)
|
|
|
|
{
|
2024-08-10 00:32:55 +02:00
|
|
|
struct lyd_node *dnode;
|
|
|
|
|
2024-08-08 00:17:11 +02:00
|
|
|
if (args->event != NB_EV_APPLY)
|
|
|
|
return NB_OK;
|
2024-08-10 00:32:55 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't keep the IP version of distribute-list anywhere, so we're
|
|
|
|
* trying to remove both. If one doesn't exist, it's simply skipped by
|
|
|
|
* the remove function.
|
|
|
|
*/
|
|
|
|
|
|
|
|
dnode = yang_dnode_get(args->dnode, "in/access-list");
|
|
|
|
if (dnode) {
|
|
|
|
distribute_list_leaf_update(dnode, 4, true);
|
|
|
|
distribute_list_leaf_update(dnode, 6, true);
|
|
|
|
}
|
|
|
|
dnode = yang_dnode_get(args->dnode, "in/prefix-list");
|
|
|
|
if (dnode) {
|
|
|
|
distribute_list_leaf_update(dnode, 4, true);
|
|
|
|
distribute_list_leaf_update(dnode, 6, true);
|
|
|
|
}
|
|
|
|
dnode = yang_dnode_get(args->dnode, "out/access-list");
|
|
|
|
if (dnode) {
|
|
|
|
distribute_list_leaf_update(dnode, 4, true);
|
|
|
|
distribute_list_leaf_update(dnode, 6, true);
|
|
|
|
}
|
|
|
|
dnode = yang_dnode_get(args->dnode, "out/prefix-list");
|
|
|
|
if (dnode) {
|
|
|
|
distribute_list_leaf_update(dnode, 4, true);
|
|
|
|
distribute_list_leaf_update(dnode, 6, true);
|
|
|
|
}
|
|
|
|
|
2024-01-21 14:12:39 +01:00
|
|
|
nb_running_unset_entry(args->dnode);
|
|
|
|
return NB_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int distribute_list_leaf_update(const struct lyd_node *dnode,
|
|
|
|
int ip_version, bool no)
|
|
|
|
{
|
2024-01-22 02:15:38 +01:00
|
|
|
struct distribute_ctx *ctx;
|
2024-01-21 14:12:39 +01:00
|
|
|
struct lyd_node *dir_node = lyd_parent(dnode);
|
|
|
|
struct lyd_node_inner *list_node = dir_node->parent;
|
|
|
|
struct lyd_node *intf_key = list_node->child;
|
|
|
|
bool ipv4 = ip_version == 4 ? true : false;
|
|
|
|
bool prefix;
|
|
|
|
|
2024-01-22 02:15:38 +01:00
|
|
|
ctx = nb_running_get_entry_non_rec(&list_node->node, NULL, false);
|
2024-01-21 14:12:39 +01:00
|
|
|
|
|
|
|
prefix = dnode->schema->name[0] == 'p' ? true : false;
|
|
|
|
if (no)
|
2024-01-22 02:15:38 +01:00
|
|
|
distribute_list_no_parser(ctx, NULL, prefix, ipv4,
|
2024-01-21 14:12:39 +01:00
|
|
|
dir_node->schema->name,
|
|
|
|
lyd_get_value(dnode),
|
|
|
|
lyd_get_value(intf_key));
|
|
|
|
else
|
2024-01-22 02:15:38 +01:00
|
|
|
distribute_list_parser(ctx, prefix, ipv4,
|
2024-01-21 14:12:39 +01:00
|
|
|
dir_node->schema->name,
|
|
|
|
lyd_get_value(dnode),
|
|
|
|
lyd_get_value(intf_key));
|
|
|
|
return NB_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int distribute_list_leaf_modify(struct nb_cb_modify_args *args,
|
|
|
|
int ip_version)
|
|
|
|
{
|
|
|
|
if (args->event != NB_EV_APPLY)
|
|
|
|
return NB_OK;
|
|
|
|
return distribute_list_leaf_update(args->dnode, ip_version, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int distribute_list_leaf_destroy(struct nb_cb_destroy_args *args,
|
|
|
|
int ip_version)
|
|
|
|
{
|
|
|
|
if (args->event != NB_EV_APPLY)
|
|
|
|
return NB_OK;
|
|
|
|
return distribute_list_leaf_update(args->dnode, ip_version, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
int group_distribute_list_ipv4_modify(struct nb_cb_modify_args *args)
|
|
|
|
{
|
|
|
|
return distribute_list_leaf_modify(args, 4);
|
|
|
|
}
|
|
|
|
int group_distribute_list_ipv4_destroy(struct nb_cb_destroy_args *args)
|
|
|
|
{
|
|
|
|
return distribute_list_leaf_destroy(args, 4);
|
|
|
|
}
|
|
|
|
int group_distribute_list_ipv6_modify(struct nb_cb_modify_args *args)
|
|
|
|
{
|
|
|
|
return distribute_list_leaf_modify(args, 6);
|
|
|
|
}
|
|
|
|
int group_distribute_list_ipv6_destroy(struct nb_cb_destroy_args *args)
|
|
|
|
{
|
|
|
|
return distribute_list_leaf_destroy(args, 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int distribute_list_leaf_cli_show(struct vty *vty,
|
|
|
|
const struct lyd_node *dnode,
|
|
|
|
int ip_version)
|
|
|
|
{
|
|
|
|
struct lyd_node *dir_node = lyd_parent(dnode);
|
|
|
|
struct lyd_node_inner *list_node = dir_node->parent;
|
|
|
|
struct lyd_node *intf_key = list_node->child;
|
|
|
|
bool ipv6 = ip_version == 6 ? true : false;
|
|
|
|
bool prefix;
|
|
|
|
|
|
|
|
prefix = dnode->schema->name[0] == 'p' ? true : false;
|
|
|
|
vty_out(vty,
|
|
|
|
" %sdistribute-list %s%s %s %s\n",
|
|
|
|
ipv6 ? "ipv6 " : "",
|
|
|
|
prefix ? "prefix " : "",
|
|
|
|
lyd_get_value(dnode),
|
|
|
|
dir_node->schema->name,
|
|
|
|
lyd_get_value(intf_key));
|
|
|
|
|
|
|
|
return NB_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void group_distribute_list_ipv4_cli_show(struct vty *vty,
|
|
|
|
const struct lyd_node *dnode,
|
|
|
|
bool show_defaults)
|
|
|
|
{
|
|
|
|
distribute_list_leaf_cli_show(vty, dnode, 4);
|
|
|
|
}
|
|
|
|
void group_distribute_list_ipv6_cli_show(struct vty *vty,
|
|
|
|
const struct lyd_node *dnode,
|
|
|
|
bool show_defaults)
|
|
|
|
{
|
|
|
|
distribute_list_leaf_cli_show(vty, dnode, 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------- */
|
|
|
|
/* Setup/Cleanup */
|
|
|
|
/* ------------- */
|
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
void distribute_list_delete(struct distribute_ctx **ctx)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2023-03-21 13:54:21 +01:00
|
|
|
hash_clean_and_free(&(*ctx)->disthash,
|
|
|
|
(void (*)(void *))distribute_free);
|
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
XFREE(MTYPE_DISTRIBUTE_CTX, (*ctx));
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
/* Initialize distribute list container */
|
|
|
|
struct distribute_ctx *distribute_list_ctx_create(struct vrf *vrf)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
struct distribute_ctx *ctx;
|
|
|
|
|
|
|
|
ctx = XCALLOC(MTYPE_DISTRIBUTE_CTX, sizeof(struct distribute_ctx));
|
|
|
|
ctx->vrf = vrf;
|
2024-01-22 22:00:43 +01:00
|
|
|
ctx->disthash =
|
|
|
|
hash_create(distribute_hash_make,
|
|
|
|
(bool (*)(const void *, const void *))distribute_cmp,
|
|
|
|
NULL);
|
lib, rip, ripng, babel, eigrp: add ctx pointer to distribute api
a distribute_ctx context pointer is returned after initialisation to the
calling daemon. this context pointer will be further used to do
discussion with distribute service. Today, there is no specific problem
with old api, since the pointer is the same in all the memory process.
but the pointer will be different if we have multiple instances. Right
now, this is not the case, but if that happens, that work will be used
for that.
distribute-list initialisation is split in two. the vty initialisation
is done at global level, while the context initialisation is done for
each routing daemon instance.
babel daemon is being equipped with a routing returning the main babel
instance.
also, a delete routine is available when the daemon routing instance is
suppressed.
a list of contexts is used inside distribute_list. This will permit
distribute_list utility to handle in the same daemon to handle more than
one context. This will be very useful in the vrf context.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-04 15:45:57 +01:00
|
|
|
return ctx;
|
|
|
|
}
|