Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some various stuff #12522

Merged
merged 10 commits into from
Dec 16, 2022
2 changes: 1 addition & 1 deletion bgpd/bgp_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ static void bgp_update_delay_process_status_change(struct peer *peer)

/* Called after event occurred, this function change status and reset
read/write and timer thread. */
void bgp_fsm_change_status(struct peer *peer, int status)
void bgp_fsm_change_status(struct peer *peer, enum bgp_fsm_status status)
{
struct bgp *bgp;
uint32_t peer_count;
Expand Down
3 changes: 2 additions & 1 deletion bgpd/bgp_fsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ extern int bgp_event_update(struct peer *, enum bgp_fsm_events event);
extern int bgp_stop(struct peer *peer);
extern void bgp_timer_set(struct peer *);
extern void bgp_routeadv_timer(struct thread *);
extern void bgp_fsm_change_status(struct peer *peer, int status);
extern void bgp_fsm_change_status(struct peer *peer,
enum bgp_fsm_status status);
extern const char *const peer_down_str[];
extern void bgp_update_delay_end(struct bgp *);
extern void bgp_maxmed_update(struct bgp *);
Expand Down
20 changes: 12 additions & 8 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -14693,7 +14693,7 @@ static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp,
{
struct listnode *node, *nnode;
struct peer *peer;
int find = 0;
bool found = false;
safi_t safi = SAFI_UNICAST;
json_object *json_neighbor = NULL;

Expand Down Expand Up @@ -14721,27 +14721,31 @@ static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp,
&& !strcmp(peer->conf_if, conf_if))
|| (peer->hostname
&& !strcmp(peer->hostname, conf_if))) {
find = 1;
found = true;
bgp_show_peer_gr_status(vty, peer,
json_neighbor);
}
} else {
if (sockunion_same(&peer->su, su)) {
find = 1;
found = true;
bgp_show_peer_gr_status(vty, peer,
json_neighbor);
}
}
if (json && find)
json_object_object_add(json, peer->host,
json_neighbor);
if (json) {
if (found)
json_object_object_add(json, peer->host,
json_neighbor);
else
json_object_free(json_neighbor);
}
}

if (find)
if (found)
break;
}

if (type == show_peer && !find) {
if (type == show_peer && !found) {
if (json)
json_object_boolean_true_add(json, "bgpNoSuchNeighbor");
else
Expand Down
19 changes: 15 additions & 4 deletions lib/agentx.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@
#include "linklist.h"
#include "lib/version.h"
#include "lib_errors.h"
#include "hook.h"
#include "libfrr.h"
#include "xref.h"

XREF_SETUP();

DEFINE_HOOK(agentx_enabled, (), ());

static int agentx_enabled = 0;
static bool agentx_enabled = false;

static struct thread_master *agentx_tm;
static struct thread *timeout_thr = NULL;
Expand Down Expand Up @@ -226,7 +228,7 @@ DEFUN (agentx_enable,
init_snmp(FRR_SMUX_NAME);
events = list_new();
agentx_events_update();
agentx_enabled = 1;
agentx_enabled = true;
hook_call(agentx_enabled);
}

Expand All @@ -245,7 +247,14 @@ DEFUN (no_agentx,
return CMD_WARNING_CONFIG_FAILED;
}

int smux_enabled(void)
static int smux_disable(void)
{
agentx_enabled = false;

return 0;
}

bool smux_enabled(void)
{
return agentx_enabled;
}
Expand All @@ -264,6 +273,8 @@ void smux_init(struct thread_master *tm)
install_node(&agentx_node);
install_element(CONFIG_NODE, &agentx_enable_cmd);
install_element(CONFIG_NODE, &no_agentx_cmd);

hook_register(frr_early_fini, smux_disable);
}

void smux_agentx_enable(void)
Expand All @@ -272,7 +283,7 @@ void smux_agentx_enable(void)
init_snmp(FRR_SMUX_NAME);
events = list_new();
agentx_events_update();
agentx_enabled = 1;
agentx_enabled = true;
}
}

Expand Down
5 changes: 4 additions & 1 deletion lib/smux.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ struct index_oid {

#define SNMP_IP6ADDRESS(V) (*var_len = sizeof(struct in6_addr), (uint8_t *)&V)

extern int smux_enabled(void);
/*
* Check to see if snmp is enabled or not
*/
extern bool smux_enabled(void);

extern void smux_init(struct thread_master *tm);
extern void smux_agentx_enable(void);
Expand Down
9 changes: 8 additions & 1 deletion lib/srv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,21 @@ const char *seg6local_context2str(char *str, size_t size,
}
}

static void srv6_locator_chunk_list_free(void *data)
{
struct srv6_locator_chunk *chunk = data;

srv6_locator_chunk_free(&chunk);
}

struct srv6_locator *srv6_locator_alloc(const char *name)
{
struct srv6_locator *locator = NULL;

locator = XCALLOC(MTYPE_SRV6_LOCATOR, sizeof(struct srv6_locator));
strlcpy(locator->name, name, sizeof(locator->name));
locator->chunks = list_new();
locator->chunks->del = (void (*)(void *))srv6_locator_chunk_free;
locator->chunks->del = srv6_locator_chunk_list_free;

QOBJ_REG(locator, srv6_locator);
return locator;
Expand Down
7 changes: 0 additions & 7 deletions lib/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,6 @@ void work_queue_run(struct thread *thread)

/* dont run items which are past their allowed retries */
if (item->ran > wq->spec.max_retries) {
/* run error handler, if any */
if (wq->spec.errorfunc)
wq->spec.errorfunc(wq, item);
work_queue_item_remove(wq, item);
continue;
}
Expand Down Expand Up @@ -317,10 +314,6 @@ void work_queue_run(struct thread *thread)
case WQ_RETRY_NOW:
/* a RETRY_NOW that gets here has exceeded max_tries, same as
* ERROR */
case WQ_ERROR: {
if (wq->spec.errorfunc)
wq->spec.errorfunc(wq, item);
}
/* fallthru */
case WQ_SUCCESS:
default: {
Expand Down
5 changes: 0 additions & 5 deletions lib/workqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ DECLARE_MTYPE(WORK_QUEUE);
/* action value, for use by item processor and item error handlers */
typedef enum {
WQ_SUCCESS = 0,
WQ_ERROR, /* Error, run error handler if provided */
WQ_RETRY_NOW, /* retry immediately */
WQ_RETRY_LATER, /* retry later, cease processing work queue */
WQ_REQUEUE, /* requeue item, continue processing work queue */
Expand Down Expand Up @@ -80,10 +79,6 @@ struct work_queue {
*/
wq_item_status (*workfunc)(struct work_queue *, void *);

/* error handling function, optional */
void (*errorfunc)(struct work_queue *,
struct work_queue_item *);

/* callback to delete user specific item data */
void (*del_item_data)(struct work_queue *, void *);

Expand Down
3 changes: 3 additions & 0 deletions ospf6d/ospf6_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ void ospf6_interface_delete(struct ospf6_interface *oi)
/* disable from area list if possible */
ospf6_area_interface_delete(oi);

if (oi->at_data.auth_key)
XFREE(MTYPE_OSPF6_AUTH_MANUAL_KEY, oi->at_data.auth_key);

/* Free BFD allocated data. */
XFREE(MTYPE_TMP, oi->bfd_config.profile);

Expand Down
3 changes: 3 additions & 0 deletions ospf6d/ospf6_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -2015,6 +2015,9 @@ static void ospf6_auth_trailer_copy_keychain_key(struct ospf6_interface *oi)
* these values
*/
oi->at_data.hash_algo = key->hash_algo;
if (oi->at_data.auth_key)
XFREE(MTYPE_OSPF6_AUTH_MANUAL_KEY,
oi->at_data.auth_key);
oi->at_data.auth_key = XSTRDUP(
MTYPE_OSPF6_AUTH_MANUAL_KEY, key->string);
oi->at_data.key_id = key->index;
Expand Down
6 changes: 0 additions & 6 deletions tests/lib/test_heavy_wq.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ static void heavy_wq_add(struct vty *vty, const char *str, int i)
return;
}

static void slow_func_err(struct work_queue *wq, struct work_queue_item *item)
{
printf("%s: running error function\n", __func__);
}

static void slow_func_del(struct work_queue *wq, void *data)
{
struct heavy_wq_node *hn = data;
Expand Down Expand Up @@ -143,7 +138,6 @@ static int heavy_wq_init(void)
heavy_wq = work_queue_new(master, "heavy_work_queue");

heavy_wq->spec.workfunc = &slow_func;
heavy_wq->spec.errorfunc = &slow_func_err;
heavy_wq->spec.del_item_data = &slow_func_del;
heavy_wq->spec.max_retries = 3;
heavy_wq->spec.hold = 1000;
Expand Down
11 changes: 10 additions & 1 deletion tests/topotests/config_timing/test_config_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,17 @@ def do_config(

return tot_delta


# Number of static routes
prefix_count = 10000
router = tgen.gears["r1"]
output = router.run("vtysh -h | grep address-sanitizer")
if output == "":
logger.info("No Address Sanitizer, generating 10000 routes")
prefix_count = 10000
else:
logger.info("Address Sanitizer build, only testing 50 routes")
prefix_count = 50

prefix_base = [
[u"10.0.0.0/8", u"11.0.0.0/8"],
[u"2100:1111:2220::/44", u"2100:3333:4440::/44"],
Expand Down
6 changes: 4 additions & 2 deletions zebra/rt_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,10 +987,12 @@ int netlink_route_change_read_unicast_internal(struct nlmsghdr *h,
}
}
}
if (nhe_id || ng)
if (nhe_id || ng) {
dplane_rib_add_multipath(afi, SAFI_UNICAST, &p, &src_p,
re, ng, startup, ctx);
else {
if (ng)
nexthop_group_delete(&ng);
} else {
/*
* I really don't see how this is possible
* but since we are testing for it let's
Expand Down
1 change: 0 additions & 1 deletion zebra/zebra_mpls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1754,7 +1754,6 @@ static void mpls_processq_init(void)

zrouter.lsp_process_q->spec.workfunc = &lsp_process;
zrouter.lsp_process_q->spec.del_item_data = &lsp_processq_del;
zrouter.lsp_process_q->spec.errorfunc = NULL;
zrouter.lsp_process_q->spec.completion_func = &lsp_processq_complete;
zrouter.lsp_process_q->spec.max_retries = 0;
zrouter.lsp_process_q->spec.hold = 10;
Expand Down
9 changes: 4 additions & 5 deletions zebra/zebra_rib.c
Original file line number Diff line number Diff line change
Expand Up @@ -3681,14 +3681,14 @@ static void rib_meta_queue_free(struct meta_queue *mq, struct list *l,
static void early_route_meta_queue_free(struct meta_queue *mq, struct list *l,
struct zebra_vrf *zvrf)
{
struct zebra_early_route *zer;
struct zebra_early_route *ere;
struct listnode *node, *nnode;

for (ALL_LIST_ELEMENTS(l, node, nnode, zer)) {
if (zvrf && zer->re->vrf_id != zvrf->vrf->vrf_id)
for (ALL_LIST_ELEMENTS(l, node, nnode, ere)) {
if (zvrf && ere->re->vrf_id != zvrf->vrf->vrf_id)
continue;

XFREE(MTYPE_RE, zer);
early_route_memory_free(ere);
node->data = NULL;
list_delete_node(l, node);
mq->size--;
Expand Down Expand Up @@ -3743,7 +3743,6 @@ static void rib_queue_init(void)

/* fill in the work queue spec */
zrouter.ribq->spec.workfunc = &meta_queue_process;
zrouter.ribq->spec.errorfunc = NULL;
zrouter.ribq->spec.completion_func = NULL;
/* XXX: TODO: These should be runtime configurable via vty */
zrouter.ribq->spec.max_retries = 3;
Expand Down