summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-08-14 14:16:10 +0200
committerGitHub <noreply@github.com>2018-08-14 14:16:10 +0200
commitd6853655b597e041b24a2b8d9367eea04d666c69 (patch)
treebcaf438322b7934b1a1a77f0800271a1b77f4b0b
parentbgpd/ospf(6)d/pimd: hide BFD commands with timers (diff)
parentMerge pull request #2823 from opensourcerouting/snap-staticd (diff)
downloadfrr-d6853655b597e041b24a2b8d9367eea04d666c69.tar.xz
frr-d6853655b597e041b24a2b8d9367eea04d666c69.zip
Merge branch 'master' into bfd-final
-rw-r--r--babeld/babel_main.c3
-rw-r--r--babeld/kernel.c13
-rw-r--r--babeld/kernel.h16
-rw-r--r--bgpd/bgp_aspath.c15
-rw-r--r--bgpd/bgp_debug.c2
-rw-r--r--bgpd/bgp_labelpool.c4
-rw-r--r--bgpd/bgp_nht.c2
-rw-r--r--bgpd/bgp_route.c14
-rw-r--r--bgpd/bgp_rpki.c8
-rwxr-xr-xconfigure.ac6
-rw-r--r--doc/Makefile.am1
-rw-r--r--isisd/dict.c41
-rw-r--r--isisd/isis_circuit.c4
-rw-r--r--isisd/isis_spf.c4
-rw-r--r--isisd/isis_te.c3
-rw-r--r--ldpd/ldp_vty_cmds.c54
-rw-r--r--lib/command.c6
-rw-r--r--lib/command.h6
-rw-r--r--lib/defun_lex.l1
-rw-r--r--lib/ferr.c7
-rw-r--r--lib/if.c16
-rw-r--r--lib/linklist.c20
-rw-r--r--lib/linklist.h13
-rw-r--r--lib/vrf.c16
-rw-r--r--lib/vty.c4
-rw-r--r--lib/workqueue.c8
-rw-r--r--nhrpd/nhrp_cache.c21
-rw-r--r--nhrpd/nhrp_interface.c2
-rw-r--r--nhrpd/nhrp_nhs.c2
-rw-r--r--nhrpd/nhrp_peer.c24
-rw-r--r--nhrpd/nhrp_vc.c17
-rw-r--r--nhrpd/zbuf.c2
-rw-r--r--ospf6d/ospf6_flood.c1
-rw-r--r--ospf6d/ospf6_interface.c6
-rw-r--r--ospf6d/ospf6_message.c8
-rw-r--r--ospf6d/ospf6_neighbor.c4
-rw-r--r--ospf6d/ospf6_spf.c6
-rw-r--r--ospfclient/ospf_apiclient.c10
-rw-r--r--ospfd/ospf_apiserver.c12
-rw-r--r--ospfd/ospf_ext.c5
-rw-r--r--ospfd/ospf_interface.c3
-rw-r--r--ospfd/ospf_lsa.c27
-rw-r--r--ospfd/ospf_opaque.c29
-rw-r--r--ospfd/ospf_spf.c3
-rw-r--r--ospfd/ospf_sr.c12
-rw-r--r--ospfd/ospf_te.c5
-rw-r--r--pbrd/pbr_vty.c3
-rw-r--r--pbrd/pbr_zebra.c6
-rw-r--r--pimd/pim_br.c1
-rw-r--r--pimd/pim_cmd.c5
-rw-r--r--pimd/pim_igmpv3.c31
-rw-r--r--pimd/pim_rp.c17
-rw-r--r--pimd/pim_vty.c5
-rw-r--r--pimd/pimd.h1
-rw-r--r--ripd/ripd.c1
-rw-r--r--snapcraft/defaults/staticd.conf.default0
-rw-r--r--snapcraft/scripts/Makefile1
-rw-r--r--snapcraft/scripts/staticd-service20
-rw-r--r--snapcraft/snapcraft.yaml.in9
-rw-r--r--staticd/static_nht.c2
-rw-r--r--staticd/static_zebra.c2
-rw-r--r--tests/lib/test_heavy_thread.c11
-rw-r--r--tests/lib/test_heavy_wq.c17
-rwxr-xr-xtools/frr-reload.py29
-rw-r--r--vtysh/Makefile.am2
-rwxr-xr-xvtysh/extract.pl.in5
-rw-r--r--vtysh/vtysh.c47
-rw-r--r--vtysh/vtysh_main.c2
-rw-r--r--zebra/if_ioctl_solaris.c6
-rw-r--r--zebra/label_manager.c2
-rw-r--r--zebra/zebra_mpls.c4
-rw-r--r--zebra/zebra_pw.c45
-rw-r--r--zebra/zebra_rib.c3
-rw-r--r--zebra/zebra_routemap.c3
-rw-r--r--zebra/zebra_vxlan.c4
75 files changed, 304 insertions, 466 deletions
diff --git a/babeld/babel_main.c b/babeld/babel_main.c
index 9ea123c8f..2b87bed0f 100644
--- a/babeld/babel_main.c
+++ b/babeld/babel_main.c
@@ -196,9 +196,6 @@ main(int argc, char **argv)
/* this replace kernel_setup && kernel_setup_socket */
babelz_zebra_init ();
- /* Get zebra configuration file. */
- vty_read_config (babeld_di.config_file, babel_config_default);
-
/* init buffer */
rc = resize_receive_buffer(1500);
if(rc < 0)
diff --git a/babeld/kernel.c b/babeld/kernel.c
index 7e78b6dec..ba2b58131 100644
--- a/babeld/kernel.c
+++ b/babeld/kernel.c
@@ -73,9 +73,9 @@ kernel_interface_wireless(struct interface *interface)
}
int
-kernel_route(int operation, const unsigned char *pref, unsigned short plen,
- const unsigned char *gate, int ifindex, unsigned int metric,
- const unsigned char *newgate, int newifindex,
+kernel_route(enum babel_kernel_routes operation, const unsigned char *pref,
+ unsigned short plen, const unsigned char *gate, int ifindex,
+ unsigned int metric, const unsigned char *newgate, int newifindex,
unsigned int newmetric)
{
int rc;
@@ -116,12 +116,9 @@ kernel_route(int operation, const unsigned char *pref, unsigned short plen,
newmetric);
return rc;
break;
- default:
- zlog_err("this should never happen (false value - kernel_route)");
- assert(0);
- exit(1);
- break;
}
+
+ return 0;
}
static int
diff --git a/babeld/kernel.h b/babeld/kernel.h
index eb1e79327..5b1437ef3 100644
--- a/babeld/kernel.h
+++ b/babeld/kernel.h
@@ -29,17 +29,19 @@ THE SOFTWARE.
#define KERNEL_INFINITY 0xFFFF
-#define ROUTE_FLUSH 0
-#define ROUTE_ADD 1
-#define ROUTE_MODIFY 2
+enum babel_kernel_routes {
+ ROUTE_FLUSH,
+ ROUTE_ADD,
+ ROUTE_MODIFY,
+};
int kernel_interface_operational(struct interface *interface);
int kernel_interface_mtu(struct interface *interface);
int kernel_interface_wireless(struct interface *interface);
-int kernel_route(int operation, const unsigned char *dest, unsigned short plen,
- const unsigned char *gate, int ifindex, unsigned int metric,
- const unsigned char *newgate, int newifindex,
- unsigned int newmetric);
+int kernel_route(enum babel_kernel_routes operation, const unsigned char *dest,
+ unsigned short plen, const unsigned char *gate, int ifindex,
+ unsigned int metric, const unsigned char *newgate,
+ int newifindex, unsigned int newmetric);
int if_eui64(int ifindex, unsigned char *eui);
int gettime(struct timeval *tv);
int read_random_bytes(void *buf, size_t len);
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index 05e67baa8..d6ad52b3a 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -214,16 +214,11 @@ static struct assegment *assegment_append_asns(struct assegment *seg,
newas = XREALLOC(MTYPE_AS_SEG_DATA, seg->as,
ASSEGMENT_DATA_SIZE(seg->length + num, 1));
- if (newas) {
- seg->as = newas;
- memcpy(seg->as + seg->length, asnos,
- ASSEGMENT_DATA_SIZE(num, 1));
- seg->length += num;
- return seg;
- }
-
- assegment_free_all(seg);
- return NULL;
+ seg->as = newas;
+ memcpy(seg->as + seg->length, asnos,
+ ASSEGMENT_DATA_SIZE(num, 1));
+ seg->length += num;
+ return seg;
}
static int int_cmp(const void *p1, const void *p2)
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index c7c36882a..f49f80b5d 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -621,7 +621,7 @@ static int bgp_debug_parse_evpn_prefix(struct vty *vty, struct cmd_token **argv,
memset(&ip, 0, sizeof(struct ipaddr));
argv_find(argv, argc, "mac", &mac_idx);
- prefix_str2mac(argv[mac_idx + 1]->arg, &mac);
+ (void)prefix_str2mac(argv[mac_idx + 1]->arg, &mac);
argv_find(argv, argc, "ip", &ip_idx);
str2ipaddr(argv[ip_idx + 1]->arg, &ip);
diff --git a/bgpd/bgp_labelpool.c b/bgpd/bgp_labelpool.c
index 2c98cd9ef..e052d6061 100644
--- a/bgpd/bgp_labelpool.c
+++ b/bgpd/bgp_labelpool.c
@@ -202,10 +202,6 @@ void bgp_lp_init(struct thread_master *master, struct labelpool *pool)
lp->requests = XCALLOC(MTYPE_BGP_LABEL_FIFO, sizeof(struct lp_fifo));
LABEL_FIFO_INIT(lp->requests);
lp->callback_q = work_queue_new(master, "label callbacks");
- if (!lp->callback_q) {
- zlog_err("%s: Failed to allocate work queue", __func__);
- exit(1);
- }
lp->callback_q->spec.workfunc = lp_cbq_docallback;
lp->callback_q->spec.del_item_data = lp_cbq_item_free;
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index 2c9e37929..8b6ff3fa2 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -88,7 +88,7 @@ int bgp_find_nexthop(struct bgp_info *path, int connected)
static void bgp_unlink_nexthop_check(struct bgp_nexthop_cache *bnc)
{
- if (LIST_EMPTY(&(bnc->paths)) && bnc->nht_info) {
+ if (LIST_EMPTY(&(bnc->paths)) && !bnc->nht_info) {
if (BGP_DEBUG(nht, NHT)) {
char buf[PREFIX2STR_BUFFER];
zlog_debug("bgp_unlink_nexthop: freeing bnc %s",
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index b66a913f5..d0dbb4221 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -2459,16 +2459,10 @@ static void bgp_processq_del(struct work_queue *wq, void *data)
void bgp_process_queue_init(void)
{
- if (!bm->process_main_queue) {
+ if (!bm->process_main_queue)
bm->process_main_queue =
work_queue_new(bm->master, "process_main_queue");
- if (!bm->process_main_queue) {
- zlog_err("%s: Failed to allocate work queue", __func__);
- exit(1);
- }
- }
-
bm->process_main_queue->spec.workfunc = &bgp_process_wq;
bm->process_main_queue->spec.del_item_data = &bgp_processq_del;
bm->process_main_queue->spec.max_retries = 0;
@@ -3838,11 +3832,7 @@ static void bgp_clear_node_queue_init(struct peer *peer)
snprintf(wname, sizeof(wname), "clear %s", peer->host);
#undef CLEAR_QUEUE_NAME_LEN
- if ((peer->clear_node_queue = work_queue_new(bm->master, wname))
- == NULL) {
- zlog_err("%s: Failed to allocate work queue", __func__);
- exit(1);
- }
+ peer->clear_node_queue = work_queue_new(bm->master, wname);
peer->clear_node_queue->spec.hold = 10;
peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node;
peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del;
diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c
index 774c48478..52c5dc5e9 100644
--- a/bgpd/bgp_rpki.c
+++ b/bgpd/bgp_rpki.c
@@ -126,7 +126,7 @@ static void print_record(const struct pfx_record *record, void *data);
static int is_synchronized(void);
static int is_running(void);
static void route_match_free(void *rule);
-static route_map_result_t route_match(void *rule, struct prefix *prefix,
+static route_map_result_t route_match(void *rule, const struct prefix *prefix,
route_map_object_t type, void *object);
static void *route_match_compile(const char *arg);
static void revalidate_bgp_node(struct bgp_node *bgp_node, afi_t afi,
@@ -190,7 +190,7 @@ static void free_tr_socket(struct cache *cache)
}
static int rpki_validate_prefix(struct peer *peer, struct attr *attr,
- struct prefix *prefix);
+ const struct prefix *prefix);
static void ipv6_addr_to_network_byte_order(const uint32_t *src, uint32_t *dest)
{
@@ -208,7 +208,7 @@ static void ipv6_addr_to_host_byte_order(const uint32_t *src, uint32_t *dest)
dest[i] = ntohl(src[i]);
}
-static route_map_result_t route_match(void *rule, struct prefix *prefix,
+static route_map_result_t route_match(void *rule, const struct prefix *prefix,
route_map_object_t type, void *object)
{
int *rpki_status = rule;
@@ -621,7 +621,7 @@ static void print_prefix_table(struct vty *vty)
}
static int rpki_validate_prefix(struct peer *peer, struct attr *attr,
- struct prefix *prefix)
+ const struct prefix *prefix)
{
struct assegment *as_segment;
as_t as_number = 0;
diff --git a/configure.ac b/configure.ac
index 9e7ca2f7e..af0c34626 100755
--- a/configure.ac
+++ b/configure.ac
@@ -356,7 +356,7 @@ AC_ARG_ENABLE(ospfd,
AC_ARG_ENABLE(ospf6d,
AS_HELP_STRING([--disable-ospf6d], [do not build ospf6d]))
AC_ARG_ENABLE(ldpd,
- AS_HELP_STRING([--enable-ldpd], [build ldpd]))
+ AS_HELP_STRING([--disable-ldpd], [do not build ldpd]))
AC_ARG_ENABLE(nhrpd,
AS_HELP_STRING([--disable-nhrpd], [do not build nhrpd]))
AC_ARG_ENABLE(eigrpd,
@@ -372,7 +372,9 @@ AC_ARG_ENABLE(pimd,
AC_ARG_ENABLE(pbrd,
AS_HELP_STRING([--disable-pbrd], [do not build pbrd]))
AC_ARG_ENABLE(sharpd,
- AS_HELP_STRING([--enable-sharpd], [do not build sharpd]))
+ AS_HELP_STRING([--enable-sharpd], [build sharpd]))
+AC_ARG_ENABLE(staticd,
+ AS_HELP_STRING([--disable-staticd], [do not build staticd]))
AC_ARG_ENABLE(bgp-announce,
AS_HELP_STRING([--disable-bgp-announce,], [turn off BGP route announcement]))
AC_ARG_ENABLE(bgp-vnc,
diff --git a/doc/Makefile.am b/doc/Makefile.am
index dce139872..1f6a0d87f 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -241,6 +241,7 @@ EXTRA_DIST = frr-sphinx.mk \
user/vtysh.rst \
user/zebra.rst \
user/bfd.rst \
+ user/flowspec.rst \
mpls/ChangeLog.opaque.txt \
mpls/ospfd.conf \
mpls/cli_summary.txt \
diff --git a/isisd/dict.c b/isisd/dict.c
index 20a4c0ff7..5d3e61e6d 100644
--- a/isisd/dict.c
+++ b/isisd/dict.c
@@ -244,19 +244,18 @@ dict_t *dict_create(dictcount_t maxcount, dict_comp_t comp)
{
dict_t *new = XCALLOC(MTYPE_ISIS_DICT, sizeof(dict_t));
- if (new) {
- new->compare = comp;
- new->allocnode = dnode_alloc;
- new->freenode = dnode_free;
- new->context = NULL;
- new->nodecount = 0;
- new->maxcount = maxcount;
- new->nilnode.left = &new->nilnode;
- new->nilnode.right = &new->nilnode;
- new->nilnode.parent = &new->nilnode;
- new->nilnode.color = dnode_black;
- new->dupes = 0;
- }
+ new->compare = comp;
+ new->allocnode = dnode_alloc;
+ new->freenode = dnode_free;
+ new->context = NULL;
+ new->nodecount = 0;
+ new->maxcount = maxcount;
+ new->nilnode.left = &new->nilnode;
+ new->nilnode.right = &new->nilnode;
+ new->nilnode.parent = &new->nilnode;
+ new->nilnode.color = dnode_black;
+ new->dupes = 0;
+
return new;
}
@@ -974,12 +973,12 @@ static void dnode_free(dnode_t *node, void *context)
dnode_t *dnode_create(void *data)
{
dnode_t *new = XCALLOC(MTYPE_ISIS_DICT_NODE, sizeof(dnode_t));
- if (new) {
- new->data = data;
- new->parent = NULL;
- new->left = NULL;
- new->right = NULL;
- }
+
+ new->data = data;
+ new->parent = NULL;
+ new->left = NULL;
+ new->right = NULL;
+
return new;
}
@@ -1250,8 +1249,8 @@ static char *dupstring(char *str)
{
int sz = strlen(str) + 1;
char *new = XCALLOC(MTYPE_ISIS_TMP, sz);
- if (new)
- memcpy(new, str, sz);
+
+ memcpy(new, str, sz);
return new;
}
diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c
index d51f31ff3..42041a7c4 100644
--- a/isisd/isis_circuit.c
+++ b/isisd/isis_circuit.c
@@ -73,10 +73,6 @@ struct isis_circuit *isis_circuit_new()
int i;
circuit = XCALLOC(MTYPE_ISIS_CIRCUIT, sizeof(struct isis_circuit));
- if (circuit == NULL) {
- zlog_err("Can't malloc isis circuit");
- return NULL;
- }
/*
* Default values
diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c
index 0a8b0e927..63f8b34be 100644
--- a/isisd/isis_spf.c
+++ b/isisd/isis_spf.c
@@ -486,10 +486,6 @@ struct isis_spftree *isis_spftree_new(struct isis_area *area)
struct isis_spftree *tree;
tree = XCALLOC(MTYPE_ISIS_SPFTREE, sizeof(struct isis_spftree));
- if (tree == NULL) {
- zlog_err("ISIS-Spf: isis_spftree_new Out of memory!");
- return NULL;
- }
isis_vertex_queue_init(&tree->tents, "IS-IS SPF tents", true);
isis_vertex_queue_init(&tree->paths, "IS-IS SPF paths", false);
diff --git a/isisd/isis_te.c b/isisd/isis_te.c
index 8e53df3b6..44ba64ce2 100644
--- a/isisd/isis_te.c
+++ b/isisd/isis_te.c
@@ -87,9 +87,6 @@ struct mpls_te_circuit *mpls_te_circuit_new()
mtc = XCALLOC(MTYPE_ISIS_MPLS_TE, sizeof(struct mpls_te_circuit));
- if (mtc == NULL)
- return NULL;
-
mtc->status = disable;
mtc->type = STD_TE;
mtc->length = 0;
diff --git a/ldpd/ldp_vty_cmds.c b/ldpd/ldp_vty_cmds.c
index d77a3e7e9..8eed08990 100644
--- a/ldpd/ldp_vty_cmds.c
+++ b/ldpd/ldp_vty_cmds.c
@@ -29,7 +29,7 @@
#include "ldpd/ldp_vty_cmds_clippy.c"
#endif
-DEFUN_NOSH(ldp_mpls_ldp,
+DEFPY_NOSH(ldp_mpls_ldp,
ldp_mpls_ldp_cmd,
"mpls ldp",
"Global MPLS configuration subcommands\n"
@@ -48,21 +48,15 @@ DEFPY (no_ldp_mpls_ldp,
return (ldp_vty_mpls_ldp(vty, "no"));
}
-DEFUN_NOSH(ldp_l2vpn,
+DEFPY_NOSH(ldp_l2vpn,
ldp_l2vpn_cmd,
- "l2vpn WORD type vpls",
+ "l2vpn WORD$l2vpn_name type vpls",
"Configure l2vpn commands\n"
"L2VPN name\n"
"L2VPN type\n"
"Virtual Private LAN Service\n")
{
- int idx = 0;
- const char *name;
-
- argv_find(argv, argc, "WORD", &idx);
- name = argv[idx]->arg;
-
- return (ldp_vty_l2vpn(vty, 0, name));
+ return (ldp_vty_l2vpn(vty, NULL, l2vpn_name));
}
DEFPY (no_ldp_l2vpn,
@@ -77,20 +71,14 @@ DEFPY (no_ldp_l2vpn,
return (ldp_vty_l2vpn(vty, "no", l2vpn_name));
}
-DEFUN_NOSH(ldp_address_family,
+DEFPY_NOSH(ldp_address_family,
ldp_address_family_cmd,
- "address-family <ipv4|ipv6>",
+ "address-family <ipv4|ipv6>$af",
"Configure Address Family and its parameters\n"
"IPv4\n"
"IPv6\n")
{
- int idx = 0;
- const char *af;
-
- argv_find(argv, argc, "address-family", &idx);
- af = argv[idx + 1]->text;
-
- return (ldp_vty_address_family(vty, 0, af));
+ return (ldp_vty_address_family(vty, NULL, af));
}
DEFPY (no_ldp_address_family,
@@ -104,7 +92,7 @@ DEFPY (no_ldp_address_family,
return (ldp_vty_address_family(vty, "no", af));
}
-DEFUN_NOSH(ldp_exit_address_family,
+DEFPY_NOSH(ldp_exit_address_family,
ldp_exit_address_family_cmd,
"exit-address-family",
"Exit from Address Family configuration mode\n")
@@ -361,19 +349,13 @@ DEFPY (ldp_session_holdtime,
return (ldp_vty_af_session_holdtime(vty, no, holdtime));
}
-DEFUN_NOSH(ldp_interface,
+DEFPY_NOSH(ldp_interface,
ldp_interface_cmd,
- "interface IFNAME",
+ "interface IFNAME$ifname",
"Enable LDP on an interface and enter interface submode\n"
"Interface's name\n")
{
- int idx = 0;
- const char *ifname;
-
- argv_find(argv, argc, "IFNAME", &idx);
- ifname = argv[idx]->arg;
-
- return (ldp_vty_interface(vty, 0, ifname));
+ return (ldp_vty_interface(vty, NULL, ifname));
}
DEFPY (no_ldp_interface,
@@ -439,20 +421,14 @@ DEFPY (ldp_member_interface,
return (ldp_vty_l2vpn_interface(vty, no, ifname));
}
-DEFUN_NOSH(ldp_member_pseudowire,
+DEFPY_NOSH(ldp_member_pseudowire,
ldp_member_pseudowire_cmd,
- "member pseudowire IFNAME",
+ "member pseudowire IFNAME$ifname",
"L2VPN member configuration\n"
"Pseudowire interface\n"
"Interface's name\n")
{
- int idx = 0;
- const char *ifname;
-
- argv_find(argv, argc, "IFNAME", &idx);
- ifname = argv[idx]->arg;
-
- return (ldp_vty_l2vpn_pseudowire(vty, 0, ifname));
+ return (ldp_vty_l2vpn_pseudowire(vty, NULL, ifname));
}
DEFPY (no_ldp_member_pseudowire,
@@ -759,7 +735,7 @@ DEFPY (ldp_show_l2vpn_atom_vc,
return (ldp_vty_show_atom_vc(vty, peer_str, ifname, vcid_str, json));
}
-DEFUN_NOSH (ldp_show_debugging_mpls_ldp,
+DEFPY_NOSH (ldp_show_debugging_mpls_ldp,
ldp_show_debugging_mpls_ldp_cmd,
"show debugging [mpls ldp]",
"Show running system information\n"
diff --git a/lib/command.c b/lib/command.c
index 884e47729..7eda239ee 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -2420,11 +2420,7 @@ static int set_log_file(struct vty *vty, const char *fname, int loglevel)
return CMD_WARNING_CONFIG_FAILED;
}
- if ((p = XMALLOC(MTYPE_TMP, strlen(cwd) + strlen(fname) + 2))
- == NULL) {
- zlog_err("config_log_file: Unable to alloc mem!");
- return CMD_WARNING_CONFIG_FAILED;
- }
+ p = XMALLOC(MTYPE_TMP, strlen(cwd) + strlen(fname) + 2);
sprintf(p, "%s/%s", cwd, fname);
fullpath = p;
} else
diff --git a/lib/command.h b/lib/command.h
index e78de2d6c..75b69507e 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -222,6 +222,9 @@ struct cmd_node {
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \
funcdecl_##funcname
+#define DEFPY_NOSH(funcname, cmdname, cmdstr, helpstr) \
+ DEFPY(funcname, cmdname, cmdstr, helpstr)
+
#define DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0) \
funcdecl_##funcname
@@ -304,6 +307,9 @@ struct cmd_node {
#define DEFPY(funcname, cmdname, cmdstr, helpstr) \
DEFUN(funcname, cmdname, cmdstr, helpstr)
+#define DEFPY_NOSH(funcname, cmdname, cmdstr, helpstr) \
+ DEFUN_NOSH(funcname, cmdname, cmdstr, helpstr)
+
#define DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \
DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, attr)
#endif /* VTYSH_EXTRACT_PL */
diff --git a/lib/defun_lex.l b/lib/defun_lex.l
index 9c995db26..d901c26a2 100644
--- a/lib/defun_lex.l
+++ b/lib/defun_lex.l
@@ -132,6 +132,7 @@ SPECIAL [(),]
"DEFUN_NOSH" value = strdup(yytext); return DEFUNNY;
"DEFUN_HIDDEN" value = strdup(yytext); return DEFUNNY;
"DEFPY" value = strdup(yytext); return DEFUNNY;
+"DEFPY_NOSH" value = strdup(yytext); return DEFUNNY;
"DEFPY_ATTR" value = strdup(yytext); return DEFUNNY;
"DEFPY_HIDDEN" value = strdup(yytext); return DEFUNNY;
"ALIAS" value = strdup(yytext); return DEFUNNY;
diff --git a/lib/ferr.c b/lib/ferr.c
index d315cf843..45574520a 100644
--- a/lib/ferr.c
+++ b/lib/ferr.c
@@ -70,13 +70,6 @@ static ferr_r ferr_set_va(const char *file, int line, const char *func,
if (!error) {
error = XCALLOC(MTYPE_ERRINFO, sizeof(*error));
- if (!error) {
- /* we're screwed */
- zlog_err("out of memory while allocating error info");
- raise(SIGSEGV);
- abort(); /* raise() can return, but raise(SIGSEGV) shall
- not */
- }
pthread_setspecific(errkey, error);
}
diff --git a/lib/if.c b/lib/if.c
index e31ccd856..dd7d21038 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -626,7 +626,7 @@ static struct interface *if_sunwzebra_get(char *name, vrf_id_t vrf_id)
}
#endif /* SUNOS_5 */
-DEFUN (interface,
+DEFUN_NOSH (interface,
interface_cmd,
"interface IFNAME [vrf NAME]",
"Select an interface to configure\n"
@@ -669,13 +669,13 @@ DEFUN (interface,
return CMD_SUCCESS;
}
-DEFUN_NOSH (no_interface,
- no_interface_cmd,
- "no interface IFNAME [vrf NAME]",
- NO_STR
- "Delete a pseudo interface's configuration\n"
- "Interface's name\n"
- VRF_CMD_HELP_STR)
+DEFUN (no_interface,
+ no_interface_cmd,
+ "no interface IFNAME [vrf NAME]",
+ NO_STR
+ "Delete a pseudo interface's configuration\n"
+ "Interface's name\n"
+ VRF_CMD_HELP_STR)
{
int idx_vrf = 4;
const char *ifname = argv[2]->arg;
diff --git a/lib/linklist.c b/lib/linklist.c
index 86649dd49..effd384e4 100644
--- a/lib/linklist.c
+++ b/lib/linklist.c
@@ -70,6 +70,26 @@ void listnode_add(struct list *list, void *val)
list->count++;
}
+void listnode_add_head(struct list *list, void *val)
+{
+ struct listnode *node;
+
+ assert(val != NULL);
+
+ node = listnode_new();
+
+ node->next = list->head;
+ node->data = val;
+
+ if (list->head == NULL)
+ list->head = node;
+ else
+ list->head->prev = node;
+ list->head = node;
+
+ list->count++;
+}
+
void listnode_add_sort(struct list *list, void *val)
{
struct listnode *n;
diff --git a/lib/linklist.h b/lib/linklist.h
index cee6c1e50..f5cd44efb 100644
--- a/lib/linklist.h
+++ b/lib/linklist.h
@@ -83,6 +83,19 @@ extern struct list *list_new(void);
extern void listnode_add(struct list *list, void *data);
/*
+ * Add a new element to the beginning of a list.
+ *
+ * Runtime is O(1).
+ *
+ * list
+ * list to operate on
+ *
+ * data
+ * element to add
+ */
+extern void listnode_add_head(struct list *list, void *data);
+
+/*
* Insert a new element into a list with insertion sort.
*
* If list->cmp is set, this function is used to determine the position to
diff --git a/lib/vrf.c b/lib/vrf.c
index ca50c1e70..4f29bad5f 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -711,12 +711,12 @@ DEFUN_NOSH (vrf,
return vrf_handler_create(vty, vrfname, NULL);
}
-DEFUN_NOSH (no_vrf,
- no_vrf_cmd,
- "no vrf NAME",
- NO_STR
- "Delete a pseudo VRF's configuration\n"
- "VRF's name\n")
+DEFUN (no_vrf,
+ no_vrf_cmd,
+ "no vrf NAME",
+ NO_STR
+ "Delete a pseudo VRF's configuration\n"
+ "VRF's name\n")
{
const char *vrfname = argv[2]->arg;
@@ -744,7 +744,7 @@ DEFUN_NOSH (no_vrf,
struct cmd_node vrf_node = {VRF_NODE, "%s(config-vrf)# ", 1};
-DEFUN (vrf_netns,
+DEFUN_NOSH (vrf_netns,
vrf_netns_cmd,
"netns NAME",
"Attach VRF to a Namespace\n"
@@ -771,7 +771,7 @@ DEFUN (vrf_netns,
return ret;
}
-DEFUN (no_vrf_netns,
+DEFUN_NOSH (no_vrf_netns,
no_vrf_netns_cmd,
"no netns [NAME]",
NO_STR
diff --git a/lib/vty.c b/lib/vty.c
index 937876c14..15e934b70 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2307,9 +2307,9 @@ void vty_close(struct vty *vty)
* additionally, we'd need to replace these fds with /dev/null. */
if (vty->wfd > STDERR_FILENO && vty->wfd != vty->fd)
close(vty->wfd);
- if (vty->fd > STDERR_FILENO) {
+ if (vty->fd > STDERR_FILENO)
close(vty->fd);
- } else
+ if (vty->fd == STDIN_FILENO)
was_stdio = true;
if (vty->buf)
diff --git a/lib/workqueue.c b/lib/workqueue.c
index 39dd142af..c927d5d71 100644
--- a/lib/workqueue.c
+++ b/lib/workqueue.c
@@ -81,9 +81,6 @@ struct work_queue *work_queue_new(struct thread_master *m,
new = XCALLOC(MTYPE_WORK_QUEUE, sizeof(struct work_queue));
- if (new == NULL)
- return new;
-
new->name = XSTRDUP(MTYPE_WORK_QUEUE_NAME, queue_name);
new->master = m;
SET_FLAG(new->flags, WQ_UNPLUGGED);
@@ -152,10 +149,7 @@ void work_queue_add(struct work_queue *wq, void *data)
assert(wq);
- if (!(item = work_queue_item_new(wq))) {
- zlog_err("%s: unable to get new queue item", __func__);
- return;
- }
+ item = work_queue_item_new(wq);
item->data = data;
work_queue_item_enqueue(wq, item);
diff --git a/nhrpd/nhrp_cache.c b/nhrpd/nhrp_cache.c
index ffc8b5a9b..f3a33eb28 100644
--- a/nhrpd/nhrp_cache.c
+++ b/nhrpd/nhrp_cache.c
@@ -48,17 +48,16 @@ static void *nhrp_cache_alloc(void *data)
struct nhrp_cache *p, *key = data;
p = XMALLOC(MTYPE_NHRP_CACHE, sizeof(struct nhrp_cache));
- if (p) {
- *p = (struct nhrp_cache){
- .cur.type = NHRP_CACHE_INVALID,
- .new.type = NHRP_CACHE_INVALID,
- .remote_addr = key->remote_addr,
- .ifp = key->ifp,
- .notifier_list =
- NOTIFIER_LIST_INITIALIZER(&p->notifier_list),
- };
- nhrp_cache_counts[p->cur.type]++;
- }
+
+ *p = (struct nhrp_cache){
+ .cur.type = NHRP_CACHE_INVALID,
+ .new.type = NHRP_CACHE_INVALID,
+ .remote_addr = key->remote_addr,
+ .ifp = key->ifp,
+ .notifier_list =
+ NOTIFIER_LIST_INITIALIZER(&p->notifier_list),
+ };
+ nhrp_cache_counts[p->cur.type]++;
return p;
}
diff --git a/nhrpd/nhrp_interface.c b/nhrpd/nhrp_interface.c
index 054a375cb..3a4271274 100644
--- a/nhrpd/nhrp_interface.c
+++ b/nhrpd/nhrp_interface.c
@@ -25,8 +25,6 @@ static int nhrp_if_new_hook(struct interface *ifp)
afi_t afi;
nifp = XCALLOC(MTYPE_NHRP_IF, sizeof(struct nhrp_interface));
- if (!nifp)
- return 0;
ifp->info = nifp;
nifp->ifp = ifp;
diff --git a/nhrpd/nhrp_nhs.c b/nhrpd/nhrp_nhs.c
index a7a8c2019..360972c32 100644
--- a/nhrpd/nhrp_nhs.c
+++ b/nhrpd/nhrp_nhs.c
@@ -324,8 +324,6 @@ int nhrp_nhs_add(struct interface *ifp, afi_t afi, union sockunion *proto_addr,
}
nhs = XMALLOC(MTYPE_NHRP_NHS, sizeof(struct nhrp_nhs));
- if (!nhs)
- return NHRP_ERR_NO_MEMORY;
*nhs = (struct nhrp_nhs){
.afi = afi,
diff --git a/nhrpd/nhrp_peer.c b/nhrpd/nhrp_peer.c
index 8952a282e..44271d68a 100644
--- a/nhrpd/nhrp_peer.c
+++ b/nhrpd/nhrp_peer.c
@@ -165,18 +165,18 @@ static void *nhrp_peer_create(void *data)
struct nhrp_peer *p, *key = data;
p = XMALLOC(MTYPE_NHRP_PEER, sizeof(*p));
- if (p) {
- *p = (struct nhrp_peer){
- .ref = 0,
- .ifp = key->ifp,
- .vc = key->vc,
- .notifier_list =
- NOTIFIER_LIST_INITIALIZER(&p->notifier_list),
- };
- nhrp_vc_notify_add(p->vc, &p->vc_notifier, nhrp_peer_vc_notify);
- nhrp_interface_notify_add(p->ifp, &p->ifp_notifier,
- nhrp_peer_ifp_notify);
- }
+
+ *p = (struct nhrp_peer){
+ .ref = 0,
+ .ifp = key->ifp,
+ .vc = key->vc,
+ .notifier_list =
+ NOTIFIER_LIST_INITIALIZER(&p->notifier_list),
+ };
+ nhrp_vc_notify_add(p->vc, &p->vc_notifier, nhrp_peer_vc_notify);
+ nhrp_interface_notify_add(p->ifp, &p->ifp_notifier,
+ nhrp_peer_ifp_notify);
+
return p;
}
diff --git a/nhrpd/nhrp_vc.c b/nhrpd/nhrp_vc.c
index c373411d6..41a87d4ad 100644
--- a/nhrpd/nhrp_vc.c
+++ b/nhrpd/nhrp_vc.c
@@ -48,14 +48,13 @@ static void *nhrp_vc_alloc(void *data)
struct nhrp_vc *vc, *key = data;
vc = XMALLOC(MTYPE_NHRP_VC, sizeof(struct nhrp_vc));
- if (vc) {
- *vc = (struct nhrp_vc){
- .local.nbma = key->local.nbma,
- .remote.nbma = key->remote.nbma,
- .notifier_list =
- NOTIFIER_LIST_INITIALIZER(&vc->notifier_list),
- };
- }
+
+ *vc = (struct nhrp_vc){
+ .local.nbma = key->local.nbma,
+ .remote.nbma = key->remote.nbma,
+ .notifier_list =
+ NOTIFIER_LIST_INITIALIZER(&vc->notifier_list),
+ };
return vc;
}
@@ -118,8 +117,6 @@ int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc)
return 0;
sa = XMALLOC(MTYPE_NHRP_VC, sizeof(struct child_sa));
- if (!sa)
- return 0;
*sa = (struct child_sa){
.id = child_id,
diff --git a/nhrpd/zbuf.c b/nhrpd/zbuf.c
index 65232a309..6e7cad8ae 100644
--- a/nhrpd/zbuf.c
+++ b/nhrpd/zbuf.c
@@ -25,8 +25,6 @@ struct zbuf *zbuf_alloc(size_t size)
struct zbuf *zb;
zb = XMALLOC(MTYPE_ZBUF_DATA, sizeof(*zb) + size);
- if (!zb)
- return NULL;
zbuf_init(zb, zb + 1, size, 0);
zb->allocated = 1;
diff --git a/ospf6d/ospf6_flood.c b/ospf6d/ospf6_flood.c
index ae26668c8..2059d8486 100644
--- a/ospf6d/ospf6_flood.c
+++ b/ospf6d/ospf6_flood.c
@@ -347,7 +347,6 @@ void ospf6_flood_interface(struct ospf6_neighbor *from, struct ospf6_lsa *lsa,
"Received is newer, remove requesting");
if (req == on->last_ls_req) {
ospf6_lsa_unlock(req);
- req = NULL;
on->last_ls_req = NULL;
}
if (req)
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index 9178bf2f6..9777a01ae 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -180,12 +180,6 @@ struct ospf6_interface *ospf6_interface_create(struct interface *ifp)
oi = (struct ospf6_interface *)XCALLOC(MTYPE_OSPF6_IF,
sizeof(struct ospf6_interface));
- if (!oi) {
- zlog_err("Can't malloc ospf6_interface for ifindex %d",
- ifp->ifindex);
- return (struct ospf6_interface *)NULL;
- }
-
oi->area = (struct ospf6_area *)NULL;
oi->neighbor_list = list_new();
oi->neighbor_list->cmp = ospf6_neighbor_cmp;
diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c
index c608a0110..c7cd94bd3 100644
--- a/ospf6d/ospf6_message.c
+++ b/ospf6d/ospf6_message.c
@@ -1503,14 +1503,6 @@ int ospf6_iobuf_size(unsigned int size)
recvnew = XMALLOC(MTYPE_OSPF6_MESSAGE, size);
sendnew = XMALLOC(MTYPE_OSPF6_MESSAGE, size);
- if (recvnew == NULL || sendnew == NULL) {
- if (recvnew)
- XFREE(MTYPE_OSPF6_MESSAGE, recvnew);
- if (sendnew)
- XFREE(MTYPE_OSPF6_MESSAGE, sendnew);
- zlog_debug("Could not allocate I/O buffer of size %d.", size);
- return iobuflen;
- }
if (recvbuf)
XFREE(MTYPE_OSPF6_MESSAGE, recvbuf);
diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c
index b5a1812ff..0cc7294d6 100644
--- a/ospf6d/ospf6_neighbor.c
+++ b/ospf6d/ospf6_neighbor.c
@@ -84,10 +84,6 @@ struct ospf6_neighbor *ospf6_neighbor_create(uint32_t router_id,
on = (struct ospf6_neighbor *)XMALLOC(MTYPE_OSPF6_NEIGHBOR,
sizeof(struct ospf6_neighbor));
- if (on == NULL) {
- zlog_warn("neighbor: malloc failed");
- return NULL;
- }
memset(on, 0, sizeof(struct ospf6_neighbor));
inet_ntop(AF_INET, &router_id, buf, sizeof(buf));
diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c
index 5b6691e6b..69c18ab75 100644
--- a/ospf6d/ospf6_spf.c
+++ b/ospf6d/ospf6_spf.c
@@ -1012,16 +1012,10 @@ struct ospf6_lsa *ospf6_create_single_router_lsa(struct ospf6_area *area,
/* Allocate memory for this LSA */
new_header = XMALLOC(MTYPE_OSPF6_LSA_HEADER, total_lsa_length);
- if (!new_header)
- return NULL;
/* LSA information structure */
lsa = (struct ospf6_lsa *)XCALLOC(MTYPE_OSPF6_LSA,
sizeof(struct ospf6_lsa));
- if (!lsa) {
- free(new_header);
- return NULL;
- }
lsa->header = (struct ospf6_lsa_header *)new_header;
diff --git a/ospfclient/ospf_apiclient.c b/ospfclient/ospf_apiclient.c
index 5b46059d7..db624ae07 100644
--- a/ospfclient/ospf_apiclient.c
+++ b/ospfclient/ospf_apiclient.c
@@ -570,10 +570,7 @@ static void ospf_apiclient_handle_lsa_update(struct ospf_apiclient *oclient,
/* Extract LSA from message */
lsalen = ntohs(cn->data.length);
lsa = XMALLOC(MTYPE_OSPF_APICLIENT, lsalen);
- if (!lsa) {
- fprintf(stderr, "LSA update: Cannot allocate memory for LSA\n");
- return;
- }
+
memcpy(lsa, &(cn->data), lsalen);
/* Invoke registered update callback function */
@@ -598,10 +595,7 @@ static void ospf_apiclient_handle_lsa_delete(struct ospf_apiclient *oclient,
/* Extract LSA from message */
lsalen = ntohs(cn->data.length);
lsa = XMALLOC(MTYPE_OSPF_APICLIENT, lsalen);
- if (!lsa) {
- fprintf(stderr, "LSA delete: Cannot allocate memory for LSA\n");
- return;
- }
+
memcpy(lsa, &(cn->data), lsalen);
/* Invoke registered update callback function */
diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c
index 8f8900e14..c0ce971f0 100644
--- a/ospfd/ospf_apiserver.c
+++ b/ospfd/ospf_apiserver.c
@@ -1176,13 +1176,11 @@ int ospf_apiserver_handle_register_event(struct ospf_apiserver *apiserv,
apiserv->filter =
XMALLOC(MTYPE_OSPF_APISERVER_MSGFILTER, ntohs(msg->hdr.msglen));
- if (apiserv->filter) {
- /* copy it over. */
- memcpy(apiserv->filter, &rmsg->filter, ntohs(msg->hdr.msglen));
- rc = OSPF_API_OK;
- } else {
- rc = OSPF_API_NOMEMORY;
- }
+
+ /* copy it over. */
+ memcpy(apiserv->filter, &rmsg->filter, ntohs(msg->hdr.msglen));
+ rc = OSPF_API_OK;
+
/* Send a reply back to client with return code */
rc = ospf_apiserver_send_reply(apiserv, seqnum, rc);
return rc;
diff --git a/ospfd/ospf_ext.c b/ospfd/ospf_ext.c
index 331cba44a..b8d14c351 100644
--- a/ospfd/ospf_ext.c
+++ b/ospfd/ospf_ext.c
@@ -545,11 +545,6 @@ static int ospf_ext_link_new_if(struct interface *ifp)
}
new = XCALLOC(MTYPE_OSPF_EXT_PARAMS, sizeof(struct ext_itf));
- if (new == NULL) {
- zlog_warn("EXT (%s): XCALLOC: %s", __func__,
- safe_strerror(errno));
- return rc;
- }
/* initialize new information and link back the interface */
new->ifp = ifp;
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index 23353b3c3..24584f671 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -523,9 +523,6 @@ static struct ospf_if_params *ospf_new_if_params(void)
oip = XCALLOC(MTYPE_OSPF_IF_PARAMS, sizeof(struct ospf_if_params));
- if (!oip)
- return NULL;
-
UNSET_IF_PARAM(oip, output_cost_cmd);
UNSET_IF_PARAM(oip, transmit_delay);
UNSET_IF_PARAM(oip, retransmit_interval);
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index 416533883..2651cf717 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -2912,24 +2912,17 @@ void ospf_lsa_maxage(struct ospf *ospf, struct ospf_lsa *lsa)
lsa_prefix.prefixlen = sizeof(lsa_prefix.u.ptr) * CHAR_BIT;
lsa_prefix.u.ptr = (uintptr_t)lsa;
- if ((rn = route_node_get(ospf->maxage_lsa,
- (struct prefix *)&lsa_prefix))
- != NULL) {
- if (rn->info != NULL) {
- if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
- zlog_debug(
- "LSA[%s]: found LSA (%p) in table for LSA %p %d",
- dump_lsa_key(lsa), rn->info,
- (void *)lsa, lsa_prefix.prefixlen);
- route_unlock_node(rn);
- } else {
- rn->info = ospf_lsa_lock(lsa);
- SET_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE);
- }
+ rn = route_node_get(ospf->maxage_lsa, (struct prefix *)&lsa_prefix);
+ if (rn->info != NULL) {
+ if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
+ zlog_debug(
+ "LSA[%s]: found LSA (%p) in table for LSA %p %d",
+ dump_lsa_key(lsa), rn->info,
+ (void *)lsa, lsa_prefix.prefixlen);
+ route_unlock_node(rn);
} else {
- zlog_err("Unable to allocate memory for maxage lsa %s\n",
- dump_lsa_key(lsa));
- assert(0);
+ rn->info = ospf_lsa_lock(lsa);
+ SET_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE);
}
if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index 1ae9a29a1..be62eb390 100644
--- a/ospfd/ospf_opaque.c
+++ b/ospfd/ospf_opaque.c
@@ -399,13 +399,8 @@ int ospf_register_opaque_functab(
}
}
- if ((new = XCALLOC(MTYPE_OSPF_OPAQUE_FUNCTAB,
- sizeof(struct ospf_opaque_functab)))
- == NULL) {
- zlog_warn("ospf_register_opaque_functab: XMALLOC: %s",
- safe_strerror(errno));
- goto out;
- }
+ new = XCALLOC(MTYPE_OSPF_OPAQUE_FUNCTAB,
+ sizeof(struct ospf_opaque_functab));
new->opaque_type = opaque_type;
new->oipt = NULL;
@@ -554,13 +549,8 @@ register_opaque_info_per_type(struct ospf_opaque_functab *functab,
struct ospf *top;
struct opaque_info_per_type *oipt;
- if ((oipt = XCALLOC(MTYPE_OPAQUE_INFO_PER_TYPE,
- sizeof(struct opaque_info_per_type)))
- == NULL) {
- zlog_warn("register_opaque_info_per_type: XMALLOC: %s",
- safe_strerror(errno));
- goto out;
- }
+ oipt = XCALLOC(MTYPE_OPAQUE_INFO_PER_TYPE,
+ sizeof(struct opaque_info_per_type));
switch (new->data->type) {
case OSPF_OPAQUE_LINK_LSA:
@@ -711,13 +701,9 @@ register_opaque_info_per_id(struct opaque_info_per_type *oipt,
{
struct opaque_info_per_id *oipi;
- if ((oipi = XCALLOC(MTYPE_OPAQUE_INFO_PER_ID,
- sizeof(struct opaque_info_per_id)))
- == NULL) {
- zlog_warn("register_opaque_info_per_id: XMALLOC: %s",
- safe_strerror(errno));
- goto out;
- }
+ oipi = XCALLOC(MTYPE_OPAQUE_INFO_PER_ID,
+ sizeof(struct opaque_info_per_id));
+
oipi->opaque_id = GET_OPAQUE_ID(ntohl(new->data->id.s_addr));
oipi->t_opaque_lsa_self = NULL;
oipi->opqctl_type = oipt;
@@ -725,7 +711,6 @@ register_opaque_info_per_id(struct opaque_info_per_type *oipt,
listnode_add(oipt->id_list, oipi);
-out:
return oipi;
}
diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c
index c6c16e716..e3c729f65 100644
--- a/ospfd/ospf_spf.c
+++ b/ospfd/ospf_spf.c
@@ -154,9 +154,6 @@ static struct vertex_parent *vertex_parent_new(struct vertex *v, int backlink,
new = XMALLOC(MTYPE_OSPF_VERTEX_PARENT, sizeof(struct vertex_parent));
- if (new == NULL)
- return NULL;
-
new->parent = v;
new->backlink = backlink;
new->nexthop = hop;
diff --git a/ospfd/ospf_sr.c b/ospfd/ospf_sr.c
index e5fc3e295..25983ddc5 100644
--- a/ospfd/ospf_sr.c
+++ b/ospfd/ospf_sr.c
@@ -128,12 +128,6 @@ static struct sr_node *sr_node_new(struct in_addr *rid)
/* Allocate Segment Routing node memory */
new = XCALLOC(MTYPE_OSPF_SR_PARAMS, sizeof(struct sr_node));
- /* Sanity Check */
- if (new == NULL) {
- zlog_err("SR (%s): Abort! can't create new SR node", __func__);
- return NULL;
- }
-
/* Default Algorithm, SRGB and MSD */
for (int i = 0; i < ALGORITHM_COUNT; i++)
new->algo[i] = SR_ALGORITHM_UNSET;
@@ -735,9 +729,6 @@ static struct sr_link *get_ext_link_sid(struct tlv_header *tlvh)
srl = XCALLOC(MTYPE_OSPF_SR_PARAMS, sizeof(struct sr_link));
- if (srl == NULL)
- return NULL;
-
/* Initialize TLV browsing */
length = ntohs(tlvh->length) - EXT_TLV_LINK_SIZE;
sub_tlvh = (struct tlv_header *)((char *)(tlvh) + TLV_HDR_SIZE
@@ -820,9 +811,6 @@ static struct sr_prefix *get_ext_prefix_sid(struct tlv_header *tlvh)
srp = XCALLOC(MTYPE_OSPF_SR_PARAMS, sizeof(struct sr_prefix));
- if (srp == NULL)
- return NULL;
-
/* Initialize TLV browsing */
length = ntohs(tlvh->length) - EXT_TLV_PREFIX_SIZE;
sub_tlvh = (struct tlv_header *)((char *)(tlvh) + TLV_HDR_SIZE
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index 86125d0c7..cc2d9282f 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -857,11 +857,6 @@ static int ospf_mpls_te_new_if(struct interface *ifp)
}
new = XCALLOC(MTYPE_OSPF_MPLS_TE, sizeof(struct mpls_te_link));
- if (new == NULL) {
- zlog_warn("ospf_mpls_te_new_if: XMALLOC: %s",
- safe_strerror(errno));
- return rc;
- }
new->instance = get_mpls_te_instance_value();
new->ifp = ifp;
diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c
index 44e14c547..a4b87f99d 100644
--- a/pbrd/pbr_vty.c
+++ b/pbrd/pbr_vty.c
@@ -580,6 +580,9 @@ static int pbr_interface_config_write(struct vty *vty)
vty_frame(vty, "interface %s vrf %s\n",
ifp->name, vrf->name);
+ if (ifp->desc)
+ vty_out(vty, " description %s\n", ifp->desc);
+
pbr_map_write_interfaces(vty, ifp);
vty_endframe(vty, "!\n");
diff --git a/pbrd/pbr_zebra.c b/pbrd/pbr_zebra.c
index 8d336c9d0..25d64238b 100644
--- a/pbrd/pbr_zebra.c
+++ b/pbrd/pbr_zebra.c
@@ -54,12 +54,6 @@ struct pbr_interface *pbr_if_new(struct interface *ifp)
pbr_ifp = XCALLOC(MTYPE_PBR_INTERFACE, sizeof(*pbr_ifp));
- if (!pbr_ifp) {
- zlog_err("%s: PBR XCALLOC(%zu) failure", __PRETTY_FUNCTION__,
- sizeof(*pbr_ifp));
- return 0;
- }
-
ifp->info = pbr_ifp;
return pbr_ifp;
}
diff --git a/pimd/pim_br.c b/pimd/pim_br.c
index 6184ea12c..fc6a02ec9 100644
--- a/pimd/pim_br.c
+++ b/pimd/pim_br.c
@@ -64,7 +64,6 @@ void pim_br_set_pmbr(struct prefix_sg *sg, struct in_addr br)
if (!pim_br) {
pim_br = XCALLOC(MTYPE_PIM_BR, sizeof(*pim_br));
-
pim_br->sg = *sg;
listnode_add(pim_br_list, pim_br);
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index 0d6413919..6eb4303fb 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -5106,11 +5106,6 @@ static int pim_rp_cmd_worker(struct pim_instance *pim, struct vty *vty,
result = pim_rp_new(pim, rp, group, plist);
- if (result == PIM_MALLOC_FAIL) {
- vty_out(vty, "%% Out of memory\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
if (result == PIM_GROUP_BAD_ADDRESS) {
vty_out(vty, "%% Bad group address specified: %s\n", group);
return CMD_WARNING_CONFIG_FAILED;
diff --git a/pimd/pim_igmpv3.c b/pimd/pim_igmpv3.c
index b32d71cc0..132fe4d56 100644
--- a/pimd/pim_igmpv3.c
+++ b/pimd/pim_igmpv3.c
@@ -486,9 +486,6 @@ static struct igmp_source *add_source_by_addr(struct igmp_sock *igmp,
}
src = source_new(group, src_addr);
- if (!src) {
- return 0;
- }
return src;
}
@@ -579,10 +576,6 @@ static void isex_excl(struct igmp_group *group, int num_sources,
/* E.4: if not found, create source with timer=GMI:
* (A-X-Y) */
source = source_new(group, *src_addr);
- if (!source) {
- /* ugh, internal malloc failure, skip source */
- continue;
- }
zassert(!source->t_source_timer); /* timer == 0 */
igmp_source_reset_gmi(group->group_igmp_sock, group,
source);
@@ -637,10 +630,6 @@ static void isex_incl(struct igmp_group *group, int num_sources,
/* I.4: if not found, create source with timer=0 (B-A)
*/
source = source_new(group, *src_addr);
- if (!source) {
- /* ugh, internal malloc failure, skip source */
- continue;
- }
zassert(!source->t_source_timer); /* (B-A) timer=0 */
}
@@ -720,10 +709,6 @@ static void toin_incl(struct igmp_group *group, int num_sources,
} else {
/* If not found, create new source */
source = source_new(group, *src_addr);
- if (!source) {
- /* ugh, internal malloc failure, skip source */
- continue;
- }
}
/* (B)=GMI */
@@ -765,10 +750,6 @@ static void toin_excl(struct igmp_group *group, int num_sources,
} else {
/* If not found, create new source */
source = source_new(group, *src_addr);
- if (!source) {
- /* ugh, internal malloc failure, skip source */
- continue;
- }
}
/* (A)=GMI */
@@ -854,10 +835,6 @@ static void toex_incl(struct igmp_group *group, int num_sources,
/* If source not found, create source with timer=0:
* (B-A)=0 */
source = source_new(group, *src_addr);
- if (!source) {
- /* ugh, internal malloc failure, skip source */
- continue;
- }
zassert(!source->t_source_timer); /* (B-A) timer=0 */
}
@@ -917,10 +894,6 @@ static void toex_excl(struct igmp_group *group, int num_sources,
* (A-X-Y)=Group Timer */
long group_timer_msec;
source = source_new(group, *src_addr);
- if (!source) {
- /* ugh, internal malloc failure, skip source */
- continue;
- }
zassert(!source->t_source_timer); /* timer == 0 */
group_timer_msec = igmp_group_timer_remain_msec(group);
@@ -1431,10 +1404,6 @@ static void block_excl(struct igmp_group *group, int num_sources,
* (A-X-Y)=Group Timer */
long group_timer_msec;
source = source_new(group, *src_addr);
- if (!source) {
- /* ugh, internal malloc failure, skip source */
- continue;
- }
zassert(!source->t_source_timer); /* timer == 0 */
group_timer_msec = igmp_group_timer_remain_msec(group);
diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c
index 783f93175..3b3e5eb69 100644
--- a/pimd/pim_rp.c
+++ b/pimd/pim_rp.c
@@ -102,19 +102,10 @@ void pim_rp_init(struct pim_instance *pim)
struct route_node *rn;
pim->rp_list = list_new();
- if (!pim->rp_list) {
- zlog_err("Unable to alloc rp_list");
- return;
- }
pim->rp_list->del = (void (*)(void *))pim_rp_info_free;
pim->rp_list->cmp = pim_rp_list_cmp;
pim->rp_table = route_table_init();
- if (!pim->rp_table) {
- zlog_err("Unable to alloc rp_table");
- list_delete_and_null(&pim->rp_list);
- return;
- }
rp_info = XCALLOC(MTYPE_PIM_RP, sizeof(*rp_info));
@@ -133,14 +124,6 @@ void pim_rp_init(struct pim_instance *pim)
listnode_add(pim->rp_list, rp_info);
rn = route_node_get(pim->rp_table, &rp_info->group);
- if (!rn) {
- zlog_err("Failure to get route node for pim->rp_table");
- list_delete_and_null(&pim->rp_list);
- route_table_finish(pim->rp_table);
- XFREE(MTYPE_PIM_RP, rp_info);
- return;
- }
-
rn->info = rp_info;
if (PIM_DEBUG_TRACE)
zlog_debug(
diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c
index f4d833c26..88be195be 100644
--- a/pimd/pim_vty.c
+++ b/pimd/pim_vty.c
@@ -258,6 +258,11 @@ int pim_interface_config_write(struct vty *vty)
ifp->name, vrf->name);
++writes;
+ if (ifp->desc) {
+ vty_out(vty, " description %s\n", ifp->desc);
+ ++writes;
+ }
+
if (ifp->info) {
struct pim_interface *pim_ifp = ifp->info;
diff --git a/pimd/pimd.h b/pimd/pimd.h
index 840e0d7e3..1b11dc3f7 100644
--- a/pimd/pimd.h
+++ b/pimd/pimd.h
@@ -117,7 +117,6 @@
/* PIM error codes */
#define PIM_SUCCESS 0
-#define PIM_MALLOC_FAIL -1
#define PIM_GROUP_BAD_ADDRESS -2
#define PIM_GROUP_OVERLAP -3
#define PIM_GROUP_PFXLIST_OVERLAP -4
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 8032cf2ec..a034fb4f2 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -2812,6 +2812,7 @@ DEFUN_NOSH (router_rip,
return CMD_WARNING_CONFIG_FAILED;
}
}
+
VTY_PUSH_CONTEXT(RIP_NODE, rip);
return CMD_SUCCESS;
diff --git a/snapcraft/defaults/staticd.conf.default b/snapcraft/defaults/staticd.conf.default
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/snapcraft/defaults/staticd.conf.default
diff --git a/snapcraft/scripts/Makefile b/snapcraft/scripts/Makefile
index 110f4b287..9a476c6e5 100644
--- a/snapcraft/scripts/Makefile
+++ b/snapcraft/scripts/Makefile
@@ -15,6 +15,7 @@ install:
install -D -m 0755 babeld-service $(DESTDIR)/bin/
install -D -m 0755 eigrpd-service $(DESTDIR)/bin/
install -D -m 0755 pbrd-service $(DESTDIR)/bin/
+ install -D -m 0755 staticd-service $(DESTDIR)/bin/
install -D -m 0755 set-options $(DESTDIR)/bin/
install -D -m 0755 show_version $(DESTDIR)/bin/
diff --git a/snapcraft/scripts/staticd-service b/snapcraft/scripts/staticd-service
new file mode 100644
index 000000000..3b2288164
--- /dev/null
+++ b/snapcraft/scripts/staticd-service
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+set -e -x
+
+if ! [ -e $SNAP_DATA/staticd.conf ]; then
+ if [ -e $SNAP_DATA/zebra.conf ]; then
+ # if we have a zebra.conf, but no staticd conf, then we use
+ # this file as the default config for staticd
+ cp $SNAP_DATA/zebra.conf $SNAP_DATA/staticd.conf
+ else
+ # new config, start with template
+ cp $SNAP/etc/frr/staticd.conf $SNAP_DATA/staticd.conf
+ fi
+fi
+exec $SNAP/sbin/staticd \
+ -f $SNAP_DATA/staticd.conf \
+ --pid_file $SNAP_DATA/staticd.pid \
+ --socket $SNAP_DATA/zsock \
+ --vty_socket $SNAP_DATA
+
diff --git a/snapcraft/snapcraft.yaml.in b/snapcraft/snapcraft.yaml.in
index b4e1812c8..48dc69278 100644
--- a/snapcraft/snapcraft.yaml.in
+++ b/snapcraft/snapcraft.yaml.in
@@ -113,6 +113,13 @@ apps:
- network
- network-bind
- network-control
+ staticd:
+ command: bin/staticd-service
+ daemon: simple
+ plugs:
+ - network
+ - network-bind
+ - network-control
set:
command: bin/set-options
zebra-debug:
@@ -193,6 +200,8 @@ apps:
- network
- network-bind
- network-control
+ staticd-debug:
+ command: sbin/staticd -f $SNAP_DATA/staticd.conf --pid_file $SNAP_DATA/staticd.pid --socket $SNAP_DATA/zsock --vty_socket $SNAP_DATA
parts:
frr:
diff --git a/staticd/static_nht.c b/staticd/static_nht.c
index f9f937f90..c6e4587b6 100644
--- a/staticd/static_nht.c
+++ b/staticd/static_nht.c
@@ -42,7 +42,7 @@ void static_nht_update(struct prefix *p, uint32_t nh_num,
vrf = vrf_lookup_by_id(vrf_id);
- if (!vrf->info)
+ if (!vrf || !vrf->info)
return;
svrf = vrf->info;
diff --git a/staticd/static_zebra.c b/staticd/static_zebra.c
index 27e126e2a..f3175e91f 100644
--- a/staticd/static_zebra.c
+++ b/staticd/static_zebra.c
@@ -119,7 +119,7 @@ static int interface_state_up(int command, struct zclient *zclient,
ifp = zebra_interface_if_lookup(zclient->ibuf);
- if (if_is_vrf(ifp)) {
+ if (ifp && if_is_vrf(ifp)) {
struct static_vrf *svrf = static_vrf_lookup_by_id(vrf_id);
static_fixup_vrf_ids(svrf);
diff --git a/tests/lib/test_heavy_thread.c b/tests/lib/test_heavy_thread.c
index 075bcb6da..b3c6e4c2f 100644
--- a/tests/lib/test_heavy_thread.c
+++ b/tests/lib/test_heavy_thread.c
@@ -110,16 +110,9 @@ DEFUN (clear_foo,
str = argv_concat(argv, argc, 0);
- if ((ws = XMALLOC(MTYPE_TMP, sizeof(*ws))) == NULL) {
- zlog_err("%s: unable to allocate work_state", __func__);
- return CMD_WARNING;
- }
+ ws = XMALLOC(MTYPE_TMP, sizeof(*ws));
- if (!(ws->str = XSTRDUP(MTYPE_TMP, str))) {
- zlog_err("%s: unable to xstrdup", __func__);
- XFREE(MTYPE_TMP, ws);
- return CMD_WARNING;
- }
+ ws->str = XSTRDUP(MTYPE_TMP, str);
ws->vty = vty;
ws->i = ITERS_FIRST;
diff --git a/tests/lib/test_heavy_wq.c b/tests/lib/test_heavy_wq.c
index 0f474dc5d..00ddc836d 100644
--- a/tests/lib/test_heavy_wq.c
+++ b/tests/lib/test_heavy_wq.c
@@ -60,18 +60,10 @@ static void heavy_wq_add(struct vty *vty, const char *str, int i)
{
struct heavy_wq_node *hn;
- if ((hn = XCALLOC(MTYPE_WQ_NODE, sizeof(struct heavy_wq_node)))
- == NULL) {
- zlog_err("%s: unable to allocate hn", __func__);
- return;
- }
+ hn = XCALLOC(MTYPE_WQ_NODE, sizeof(struct heavy_wq_node));
hn->i = i;
- if (!(hn->str = XSTRDUP(MTYPE_WQ_NODE_STR, str))) {
- zlog_err("%s: unable to xstrdup", __func__);
- XFREE(MTYPE_WQ_NODE, hn);
- return;
- }
+ hn->str = XSTRDUP(MTYPE_WQ_NODE_STR, str);
work_queue_add(heavy_wq, hn);
@@ -149,10 +141,7 @@ DEFUN (clear_foo,
static int heavy_wq_init()
{
- if (!(heavy_wq = work_queue_new(master, "heavy_work_queue"))) {
- zlog_err("%s: could not get new work queue!", __func__);
- return -1;
- }
+ heavy_wq = work_queue_new(master, "heavy_work_queue");
heavy_wq->spec.workfunc = &slow_func;
heavy_wq->spec.errorfunc = &slow_func_err;
diff --git a/tools/frr-reload.py b/tools/frr-reload.py
index a9f183ed7..9d1af27d6 100755
--- a/tools/frr-reload.py
+++ b/tools/frr-reload.py
@@ -413,7 +413,7 @@ end
ctx_keys = []
current_context_lines = []
- elif line in ["exit-address-family", "exit", "exit-vnc", "exit-vni"]:
+ elif line in ["exit-address-family", "exit", "exit-vnc"]:
# if this exit is for address-family ipv4 unicast, ignore the pop
if main_ctx_key:
self.save_contexts(ctx_keys, current_context_lines)
@@ -423,6 +423,15 @@ end
current_context_lines = []
log.debug('LINE %-50s: popping from subcontext to ctx%-50s', line, ctx_keys)
+ elif line == "exit-vni":
+ if sub_main_ctx_key:
+ self.save_contexts(ctx_keys, current_context_lines)
+
+ # Start a new context
+ ctx_keys = copy.deepcopy(sub_main_ctx_key)
+ current_context_lines = []
+ log.debug('LINE %-50s: popping from sub-subcontext to ctx%-50s', line, ctx_keys)
+
elif new_ctx is True:
if not main_ctx_key:
ctx_keys = [line, ]
@@ -436,11 +445,7 @@ end
elif (line.startswith("address-family ") or
line.startswith("vnc defaults") or
line.startswith("vnc l2-group") or
- line.startswith("vnc nve-group") or
- (line.startswith("vni ") and
- len(ctx_keys) == 2 and
- ctx_keys[0].startswith('router bgp') and
- ctx_keys[1] == 'address-family l2vpn evpn')):
+ line.startswith("vnc nve-group")):
main_ctx_key = []
# Save old context first
@@ -458,6 +463,18 @@ end
else:
ctx_keys.append(line)
+ elif ((line.startswith("vni ") and
+ len(ctx_keys) == 2 and
+ ctx_keys[0].startswith('router bgp') and
+ ctx_keys[1] == 'address-family l2vpn evpn')):
+
+ # Save old context first
+ self.save_contexts(ctx_keys, current_context_lines)
+ current_context_lines = []
+ sub_main_ctx_key = copy.deepcopy(ctx_keys)
+ log.debug('LINE %-50s: entering sub-sub-context, append to ctx_keys', line)
+ ctx_keys.append(line)
+
else:
# Continuing in an existing context, add non-commented lines to it
current_context_lines.append(line)
diff --git a/vtysh/Makefile.am b/vtysh/Makefile.am
index f241f3c5a..936640c83 100644
--- a/vtysh/Makefile.am
+++ b/vtysh/Makefile.am
@@ -158,7 +158,7 @@ vtysh_cmd_FILES = $(vtysh_scan) \
$(top_srcdir)/lib/keychain.c $(top_srcdir)/lib/routemap.c \
$(top_srcdir)/lib/filter.c $(top_srcdir)/lib/plist.c \
$(top_srcdir)/lib/distribute.c $(top_srcdir)/lib/if_rmap.c \
- $(top_srcdir)/lib/vrf.c \
+ $(top_srcdir)/lib/vrf.c $(top_srcdir)/lib/if.c \
$(top_srcdir)/lib/vty.c $(top_srcdir)/zebra/debug.c \
$(top_srcdir)/lib/logicalrouter.c \
$(top_srcdir)/lib/nexthop_group.c \
diff --git a/vtysh/extract.pl.in b/vtysh/extract.pl.in
index c0277b3d6..92b5686a9 100755
--- a/vtysh/extract.pl.in
+++ b/vtysh/extract.pl.in
@@ -85,7 +85,10 @@ foreach (@ARGV) {
$protocol = "VTYSH_RMAP";
}
elsif ($file =~ /lib\/vrf\.c$/) {
- $protocol = "VTYSH_ALL";
+ $protocol = "VTYSH_VRF";
+ }
+ elsif ($file =~ /lib\/if\.c$/) {
+ $protocol = "VTYSH_INTERFACE";
}
elsif ($file =~ /lib\/logicalrouter\.c$/) {
$protocol = "VTYSH_ALL";
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index d0b654d2c..48a90a695 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -2072,18 +2072,6 @@ DEFUNSH(VTYSH_ZEBRA, vtysh_pseudowire, vtysh_pseudowire_cmd,
return CMD_SUCCESS;
}
-/* TODO Implement "no interface command in isisd. */
-DEFSH(VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D
- | VTYSH_EIGRPD,
- vtysh_no_interface_cmd, "no interface IFNAME", NO_STR
- "Delete a pseudo interface's configuration\n"
- "Interface's name\n")
-
-DEFSH(VTYSH_ZEBRA, vtysh_no_interface_vrf_cmd, "no interface IFNAME vrf NAME",
- NO_STR
- "Delete a pseudo interface's configuration\n"
- "Interface's name\n" VRF_CMD_HELP_STR)
-
DEFUNSH(VTYSH_ZEBRA, vtysh_logicalrouter, vtysh_logicalrouter_cmd,
"logical-router (1-65535) ns NAME",
"Enable a logical-router\n"
@@ -2124,9 +2112,16 @@ DEFUNSH(VTYSH_VRF, vtysh_vrf, vtysh_vrf_cmd, "vrf NAME",
return CMD_SUCCESS;
}
-DEFSH(VTYSH_ZEBRA, vtysh_no_vrf_cmd, "no vrf NAME", NO_STR
- "Delete a pseudo vrf's configuration\n"
- "VRF's name\n")
+DEFSH(VTYSH_ZEBRA, vtysh_vrf_netns_cmd,
+ "netns NAME",
+ "Attach VRF to a Namespace\n"
+ "The file name in " NS_RUN_DIR ", or a full pathname\n")
+
+DEFSH(VTYSH_ZEBRA, vtysh_no_vrf_netns_cmd,
+ "no netns [NAME]",
+ NO_STR
+ "Detach VRF from a Namespace\n"
+ "The file name in " NS_RUN_DIR ", or a full pathname\n")
DEFUNSH(VTYSH_NS, vtysh_exit_logicalrouter,
vtysh_exit_logicalrouter_cmd, "exit",
@@ -2166,19 +2161,6 @@ DEFUNSH(VTYSH_VRF, vtysh_quit_nexthop_group, vtysh_quit_nexthop_group_cmd,
return vtysh_exit_nexthop_group(self, vty, argc, argv);
}
-/*
- * TODO Implement interface description commands in ripngd, ospf6d
- * and isisd.
- */
-DEFSH(VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_OSPFD | VTYSH_EIGRPD,
- vtysh_interface_desc_cmd, "description LINE...",
- "Interface specific description\n"
- "Characters describing this interface\n")
-
-DEFSH(VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_OSPFD | VTYSH_EIGRPD,
- vtysh_no_interface_desc_cmd, "no description",
- NO_STR "Interface specific description\n")
-
DEFUNSH(VTYSH_INTERFACE, vtysh_exit_interface, vtysh_exit_interface_cmd, "exit",
"Exit current mode and down to previous mode\n")
{
@@ -3650,8 +3632,6 @@ void vtysh_init_vty(void)
install_element(PBRMAP_NODE, &vtysh_end_all_cmd);
install_element(VTY_NODE, &vtysh_end_all_cmd);
- install_element(INTERFACE_NODE, &vtysh_interface_desc_cmd);
- install_element(INTERFACE_NODE, &vtysh_no_interface_desc_cmd);
install_element(INTERFACE_NODE, &vtysh_end_all_cmd);
install_element(INTERFACE_NODE, &vtysh_exit_interface_cmd);
install_element(LINK_PARAMS_NODE, &exit_link_params_cmd);
@@ -3755,17 +3735,16 @@ void vtysh_init_vty(void)
install_element(KEYCHAIN_NODE, &key_chain_cmd);
install_element(KEYCHAIN_KEY_NODE, &key_chain_cmd);
install_element(CONFIG_NODE, &vtysh_interface_cmd);
- install_element(CONFIG_NODE, &vtysh_no_interface_cmd);
- install_element(CONFIG_NODE, &vtysh_no_interface_vrf_cmd);
install_element(CONFIG_NODE, &vtysh_pseudowire_cmd);
install_element(INTERFACE_NODE, &vtysh_link_params_cmd);
install_element(ENABLE_NODE, &vtysh_show_running_config_cmd);
install_element(ENABLE_NODE, &vtysh_copy_running_config_cmd);
+ install_element(CONFIG_NODE, &vtysh_vrf_cmd);
+ install_element(VRF_NODE, &vtysh_vrf_netns_cmd);
+ install_element(VRF_NODE, &vtysh_no_vrf_netns_cmd);
install_element(VRF_NODE, &exit_vrf_config_cmd);
- install_element(CONFIG_NODE, &vtysh_vrf_cmd);
- install_element(CONFIG_NODE, &vtysh_no_vrf_cmd);
install_element(CONFIG_NODE, &vtysh_no_nexthop_group_cmd);
/* "write terminal" command. */
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c
index 7d882620e..86fa62f47 100644
--- a/vtysh/vtysh_main.c
+++ b/vtysh/vtysh_main.c
@@ -356,7 +356,7 @@ int main(int argc, char **argv, char **env)
break;
case OPTION_CONFDIR:
ditch_suid = 1; /* option disables SUID */
- strlcpy(sysconfdir, optarg, sizeof(sysconfdir));
+ snprintf(sysconfdir, sizeof(sysconfdir), "%s/", optarg);
break;
case 'N':
if (strchr(optarg, '/') || strchr(optarg, '.')) {
diff --git a/zebra/if_ioctl_solaris.c b/zebra/if_ioctl_solaris.c
index 6cf98e85f..6627787fd 100644
--- a/zebra/if_ioctl_solaris.c
+++ b/zebra/if_ioctl_solaris.c
@@ -100,11 +100,7 @@ calculate_lifc_len: /* must hold privileges to enter here */
if (needed > lastneeded || needed < lastneeded / 2) {
if (buf != NULL)
XFREE(MTYPE_TMP, buf);
- if ((buf = XMALLOC(MTYPE_TMP, needed)) == NULL) {
- zlog_warn("interface_list_ioctl: malloc failed");
- close(sock);
- return -1;
- }
+ buf = XMALLOC(MTYPE_TMP, needed);
}
lastneeded = needed;
diff --git a/zebra/label_manager.c b/zebra/label_manager.c
index b24a4b68d..f2f89fdeb 100644
--- a/zebra/label_manager.c
+++ b/zebra/label_manager.c
@@ -384,8 +384,6 @@ struct label_manager_chunk *assign_label_chunk(uint8_t proto,
}
/* otherwise create a new one */
lmc = XCALLOC(MTYPE_LM_CHUNK, sizeof(struct label_manager_chunk));
- if (!lmc)
- return NULL;
if (list_isempty(lbl_mgr.lc_list))
lmc->start = MPLS_LABEL_UNRESERVED_MIN;
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index cfe208d35..424a11546 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -550,8 +550,6 @@ static zebra_fec_t *fec_add(struct route_table *table, struct prefix *p,
if (!fec) {
fec = XCALLOC(MTYPE_FEC, sizeof(zebra_fec_t));
- if (!fec)
- return NULL;
rn->info = fec;
fec->rn = rn;
@@ -1181,8 +1179,6 @@ static zebra_nhlfe_t *nhlfe_add(zebra_lsp_t *lsp, enum lsp_types_t lsp_type,
return NULL;
nhlfe = XCALLOC(MTYPE_NHLFE, sizeof(zebra_nhlfe_t));
- if (!nhlfe)
- return NULL;
nhlfe->lsp = lsp;
nhlfe->type = lsp_type;
diff --git a/zebra/zebra_pw.c b/zebra/zebra_pw.c
index bf76f7e86..c6db1463f 100644
--- a/zebra/zebra_pw.c
+++ b/zebra/zebra_pw.c
@@ -308,15 +308,14 @@ void zebra_pw_exit(struct zebra_vrf *zvrf)
DEFUN_NOSH (pseudowire_if,
pseudowire_if_cmd,
- "[no] pseudowire IFNAME",
- NO_STR
+ "pseudowire IFNAME",
"Static pseudowire configuration\n"
"Pseudowire name\n")
{
struct zebra_vrf *zvrf;
struct zebra_pw *pw;
- int idx = 0;
const char *ifname;
+ int idx = 0;
zvrf = vrf_info_lookup(VRF_DEFAULT);
if (!zvrf)
@@ -324,19 +323,13 @@ DEFUN_NOSH (pseudowire_if,
argv_find(argv, argc, "IFNAME", &idx);
ifname = argv[idx]->arg;
+
pw = zebra_pw_find(zvrf, ifname);
if (pw && pw->protocol != ZEBRA_ROUTE_STATIC) {
vty_out(vty, "%% Pseudowire is not static\n");
return CMD_WARNING;
}
- if (argv_find(argv, argc, "no", &idx)) {
- if (!pw)
- return CMD_SUCCESS;
- zebra_pw_del(zvrf, pw);
- return CMD_SUCCESS;
- }
-
if (!pw)
pw = zebra_pw_add(zvrf, ifname, ZEBRA_ROUTE_STATIC, NULL);
VTY_PUSH_CONTEXT(PW_NODE, pw);
@@ -344,6 +337,37 @@ DEFUN_NOSH (pseudowire_if,
return CMD_SUCCESS;
}
+DEFUN (no_pseudowire_if,
+ no_pseudowire_if_cmd,
+ "no pseudowire IFNAME",
+ NO_STR
+ "Static pseudowire configuration\n"
+ "Pseudowire name\n")
+{
+ struct zebra_vrf *zvrf;
+ struct zebra_pw *pw;
+ const char *ifname;
+ int idx = 0;
+
+ zvrf = vrf_info_lookup(VRF_DEFAULT);
+ if (!zvrf)
+ return CMD_WARNING;
+
+ argv_find(argv, argc, "IFNAME", &idx);
+ ifname = argv[idx]->arg;
+
+ pw = zebra_pw_find(zvrf, ifname);
+ if (pw) {
+ if (pw->protocol != ZEBRA_ROUTE_STATIC) {
+ vty_out(vty, "%% Pseudowire is not static\n");
+ return CMD_WARNING;
+ }
+ zebra_pw_del(zvrf, pw);
+ }
+
+ return CMD_SUCCESS;
+}
+
DEFUN (pseudowire_labels,
pseudowire_labels_cmd,
"[no] mpls label local (16-1048575) remote (16-1048575)",
@@ -531,6 +555,7 @@ void zebra_pw_vty_init(void)
install_default(PW_NODE);
install_element(CONFIG_NODE, &pseudowire_if_cmd);
+ install_element(CONFIG_NODE, &no_pseudowire_if_cmd);
install_element(PW_NODE, &pseudowire_labels_cmd);
install_element(PW_NODE, &pseudowire_neighbor_cmd);
install_element(PW_NODE, &pseudowire_control_word_cmd);
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 18bd6b6cb..69f6ff9de 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -1965,7 +1965,6 @@ static struct meta_queue *meta_queue_new(void)
unsigned i;
new = XCALLOC(MTYPE_WORK_QUEUE, sizeof(struct meta_queue));
- assert(new);
for (i = 0; i < MQ_SIZE; i++) {
new->subq[i] = list_new();
@@ -2355,7 +2354,6 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
/* Lookup route node.*/
rn = srcdest_rnode_get(table, p, src_p);
- zlog_debug("Distance: %d", re->distance);
/*
* If same type of route are installed, treat it as a implicit
* withdraw.
@@ -2387,7 +2385,6 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
break;
}
- zlog_debug("same: %p distance: %d", same, same ? same->distance : -1);
/* If this route is kernel route, set FIB flag to the route. */
if (RIB_SYSTEM_ROUTE(re))
for (nexthop = re->ng.nexthop; nexthop; nexthop = nexthop->next)
diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c
index 0b48e87b1..fc17ee349 100644
--- a/zebra/zebra_routemap.c
+++ b/zebra/zebra_routemap.c
@@ -1098,9 +1098,6 @@ static void *route_match_address_prefix_len_compile(const char *arg)
prefix_len = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(uint32_t));
- if (!prefix_len)
- return prefix_len;
-
*prefix_len = tmpval;
return prefix_len;
}
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index 4955f3f77..17a25b700 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -2985,10 +2985,6 @@ static zebra_vtep_t *zvni_vtep_add(zebra_vni_t *zvni, struct in_addr *vtep_ip)
zebra_vtep_t *zvtep;
zvtep = XCALLOC(MTYPE_ZVNI_VTEP, sizeof(zebra_vtep_t));
- if (!zvtep) {
- zlog_err("Failed to alloc VTEP entry, VNI %u", zvni->vni);
- return NULL;
- }
zvtep->vtep_ip = *vtep_ip;