summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_ecommunity.c16
-rw-r--r--bgpd/bgpd.c1
-rw-r--r--ldpd/interface.c18
-rw-r--r--ldpd/labelmapping.c236
-rw-r--r--ldpd/lde_lib.c89
-rw-r--r--ldpd/ldpe.c59
-rw-r--r--ldpd/neighbor.c36
-rw-r--r--lib/command.c8
-rw-r--r--lib/vty.c18
-rw-r--r--lib/vty.h1
-rw-r--r--tests/topotests/ospf_metric_propagation/r1/show_ip_route-1.json2
-rw-r--r--tests/topotests/ospf_metric_propagation/r1/show_ip_route-2.json2
-rw-r--r--tests/topotests/ospf_metric_propagation/r1/show_ip_route-3.json2
-rw-r--r--tests/topotests/ospf_metric_propagation/r1/show_ip_route-4.json2
-rw-r--r--tests/topotests/ospf_metric_propagation/r1/show_ip_route-5.json2
-rw-r--r--tests/topotests/ospf_metric_propagation/r1/show_ip_route-6.json2
-rw-r--r--zebra/zebra_dplane.c48
17 files changed, 218 insertions, 324 deletions
diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c
index 7bf2609019..a555930137 100644
--- a/bgpd/bgp_ecommunity.c
+++ b/bgpd/bgp_ecommunity.c
@@ -445,7 +445,8 @@ bool ecommunity_node_target_match(struct ecommunity *ecom,
return match;
}
-static void ecommunity_node_target_str(char *buf, size_t bufsz, uint8_t *ptr)
+static void ecommunity_node_target_str(char *buf, size_t bufsz, uint8_t *ptr,
+ int format)
{
/*
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -458,7 +459,11 @@ static void ecommunity_node_target_str(char *buf, size_t bufsz, uint8_t *ptr)
IPV4_ADDR_COPY(&node_id, (struct in_addr *)ptr);
- snprintfrr(buf, bufsz, "NT:%pI4", &node_id);
+
+ snprintfrr(buf, bufsz, "%s%pI4%s",
+ format == ECOMMUNITY_FORMAT_COMMUNITY_LIST ? "nt " : "NT:",
+ &node_id,
+ format == ECOMMUNITY_FORMAT_COMMUNITY_LIST ? ":0" : "");
(void)ptr; /* consume value */
}
@@ -1059,7 +1064,8 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)
} else if (sub_type == ECOMMUNITY_NODE_TARGET &&
type == ECOMMUNITY_ENCODE_IP) {
ecommunity_node_target_str(
- encbuf, sizeof(encbuf), pnt);
+ encbuf, sizeof(encbuf), pnt,
+ format);
} else
unk_ecom = 1;
} else {
@@ -1272,8 +1278,8 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)
} else if (type == ECOMMUNITY_ENCODE_IP_NON_TRANS) {
sub_type = *pnt++;
if (sub_type == ECOMMUNITY_NODE_TARGET)
- ecommunity_node_target_str(encbuf,
- sizeof(encbuf), pnt);
+ ecommunity_node_target_str(
+ encbuf, sizeof(encbuf), pnt, format);
else
unk_ecom = 1;
} else if (type == ECOMMUNITY_ENCODE_OPAQUE_NON_TRANS) {
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 9d7a1f967e..f2ad51942f 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -1543,6 +1543,7 @@ void peer_xfer_config(struct peer *peer_dst, struct peer *peer_src)
peer_dst->ifname =
XSTRDUP(MTYPE_BGP_PEER_IFNAME, peer_src->ifname);
}
+ peer_dst->ttl = peer_src->ttl;
}
static int bgp_peer_conf_if_to_su_update_v4(struct peer *peer,
diff --git a/ldpd/interface.c b/ldpd/interface.c
index ad5d853b65..f0e70cbacc 100644
--- a/ldpd/interface.c
+++ b/ldpd/interface.c
@@ -138,14 +138,13 @@ void
if_update_info(struct iface *iface, struct kif *kif)
{
/* get type */
- if (kif->flags & IFF_POINTOPOINT)
+ if (CHECK_FLAG(kif->flags, IFF_POINTOPOINT))
iface->type = IF_TYPE_POINTOPOINT;
- if (kif->flags & IFF_BROADCAST &&
- kif->flags & IFF_MULTICAST)
+ if (CHECK_FLAG(kif->flags, IFF_BROADCAST) &&
+ CHECK_FLAG(kif->flags, IFF_MULTICAST))
iface->type = IF_TYPE_BROADCAST;
- if (ldpd_process == PROC_LDP_ENGINE && iface->operative &&
- !kif->operative)
+ if (ldpd_process == PROC_LDP_ENGINE && iface->operative && !kif->operative)
ldp_sync_fsm(iface, LDP_SYNC_EVT_IFACE_SHUTDOWN);
/* get index and flags */
@@ -276,8 +275,7 @@ if_start(struct iface *iface, int af)
struct iface_af *ia;
struct timeval now;
- log_debug("%s: %s address-family %s", __func__, iface->name,
- af_name(af));
+ log_debug("%s: %s address-family %s", __func__, iface->name, af_name(af));
ia = iface_af_get(iface, af);
@@ -560,8 +558,7 @@ if_join_ipv4_group(struct iface *iface, struct in_addr *addr)
{
struct in_addr if_addr;
- log_debug("%s: interface %s addr %pI4", __func__, iface->name,
- addr);
+ log_debug("%s: interface %s addr %pI4", __func__, iface->name, addr);
if_addr.s_addr = if_get_ipv4_addr(iface);
@@ -579,8 +576,7 @@ if_leave_ipv4_group(struct iface *iface, struct in_addr *addr)
{
struct in_addr if_addr;
- log_debug("%s: interface %s addr %pI4", __func__, iface->name,
- addr);
+ log_debug("%s: interface %s addr %pI4", __func__, iface->name, addr);
if_addr.s_addr = if_get_ipv4_addr(iface);
diff --git a/ldpd/labelmapping.c b/ldpd/labelmapping.c
index dcaf1cc10b..3c5a5d9991 100644
--- a/ldpd/labelmapping.c
+++ b/ldpd/labelmapping.c
@@ -47,12 +47,11 @@ send_labelmessage(struct nbr *nbr, uint16_t type, struct mapping_head *mh)
while ((me = TAILQ_FIRST(mh)) != NULL) {
/* generate pdu */
if (first) {
- if ((buf = ibuf_open(nbr->max_pdu_len +
- LDP_HDR_DEAD_LEN)) == NULL)
+ if ((buf = ibuf_open(nbr->max_pdu_len + LDP_HDR_DEAD_LEN)) == NULL)
fatal(__func__);
/* real size will be set up later */
- err |= gen_ldp_hdr(buf, 0);
+ SET_FLAG(err, gen_ldp_hdr(buf, 0));
size = LDP_HDR_SIZE;
first = 0;
@@ -63,9 +62,9 @@ send_labelmessage(struct nbr *nbr, uint16_t type, struct mapping_head *mh)
msg_size += len_fec_tlv(&me->map);
if (me->map.label != NO_LABEL)
msg_size += LABEL_TLV_SIZE;
- if (me->map.flags & F_MAP_REQ_ID)
+ if (CHECK_FLAG(me->map.flags, F_MAP_REQ_ID))
msg_size += REQID_TLV_SIZE;
- if (me->map.flags & F_MAP_STATUS)
+ if (CHECK_FLAG(me->map.flags, F_MAP_STATUS))
msg_size += STATUS_SIZE;
/* maximum pdu length exceeded, we need a new ldp pdu */
@@ -78,17 +77,17 @@ send_labelmessage(struct nbr *nbr, uint16_t type, struct mapping_head *mh)
size += msg_size;
/* append message and tlvs */
- err |= gen_msg_hdr(buf, type, msg_size);
- err |= gen_fec_tlv(buf, &me->map);
+ SET_FLAG(err, gen_msg_hdr(buf, type, msg_size));
+ SET_FLAG(err, gen_fec_tlv(buf, &me->map));
if (me->map.label != NO_LABEL)
- err |= gen_label_tlv(buf, me->map.label);
- if (me->map.flags & F_MAP_REQ_ID)
- err |= gen_reqid_tlv(buf, me->map.requestid);
- if (me->map.flags & F_MAP_PW_STATUS)
- err |= gen_pw_status_tlv(buf, me->map.pw_status);
- if (me->map.flags & F_MAP_STATUS)
- err |= gen_status_tlv(buf, me->map.st.status_code,
- me->map.st.msg_id, me->map.st.msg_type);
+ SET_FLAG(err, gen_label_tlv(buf, me->map.label));
+ if (CHECK_FLAG(me->map.flags, F_MAP_REQ_ID))
+ SET_FLAG(err, gen_reqid_tlv(buf, me->map.requestid));
+ if (CHECK_FLAG(me->map.flags, F_MAP_PW_STATUS))
+ SET_FLAG(err, gen_pw_status_tlv(buf, me->map.pw_status));
+ if (CHECK_FLAG(me->map.flags, F_MAP_STATUS))
+ SET_FLAG(err, gen_status_tlv(buf, me->map.st.status_code,
+ me->map.st.msg_id, me->map.st.msg_type));
if (err) {
ibuf_free(buf);
mapping_list_clr(mh);
@@ -172,15 +171,13 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
memset(&map, 0, sizeof(map));
map.msg_id = msg.id;
- if ((tlen = tlv_decode_fec_elm(nbr, &msg, buf, feclen,
- &map)) == -1)
+ if ((tlen = tlv_decode_fec_elm(nbr, &msg, buf, feclen, &map)) == -1)
goto err;
if (map.type == MAP_TYPE_PWID &&
- !(map.flags & F_MAP_PW_ID) &&
+ !CHECK_FLAG(map.flags, F_MAP_PW_ID) &&
type != MSG_TYPE_LABELWITHDRAW &&
type != MSG_TYPE_LABELRELEASE) {
- send_notification(nbr->tcp, S_MISS_MSG, msg.id,
- msg.type);
+ send_notification(nbr->tcp, S_MISS_MSG, msg.id, msg.type);
goto err;
}
@@ -193,8 +190,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
case MSG_TYPE_LABELMAPPING:
case MSG_TYPE_LABELREQUEST:
case MSG_TYPE_LABELABORTREQ:
- session_shutdown(nbr, S_UNKNOWN_FEC, msg.id,
- msg.type);
+ session_shutdown(nbr, S_UNKNOWN_FEC, msg.id, msg.type);
goto err;
default:
break;
@@ -211,8 +207,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
switch (type) {
case MSG_TYPE_LABELMAPPING:
case MSG_TYPE_LABELABORTREQ:
- session_shutdown(nbr, S_UNKNOWN_FEC, msg.id,
- msg.type);
+ session_shutdown(nbr, S_UNKNOWN_FEC, msg.id, msg.type);
goto err;
default:
break;
@@ -223,8 +218,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
* LDP supports the use of multiple FEC Elements per
* FEC for the Label Mapping message only.
*/
- if (type != MSG_TYPE_LABELMAPPING &&
- tlen != feclen) {
+ if (type != MSG_TYPE_LABELMAPPING && tlen != feclen) {
session_shutdown(nbr, S_BAD_TLV_VAL, msg.id, msg.type);
goto err;
}
@@ -262,10 +256,10 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
* For Label Mapping messages the Label TLV is mandatory and
* should appear right after the FEC TLV.
*/
- if (current_tlv == 1 && type == MSG_TYPE_LABELMAPPING &&
- !(tlv_type & TLV_TYPE_GENERICLABEL)) {
- send_notification(nbr->tcp, S_MISS_MSG, msg.id,
- msg.type);
+ if (current_tlv == 1 &&
+ type == MSG_TYPE_LABELMAPPING &&
+ !CHECK_FLAG(tlv_type, TLV_TYPE_GENERICLABEL)) {
+ send_notification(nbr->tcp, S_MISS_MSG, msg.id, msg.type);
goto err;
}
@@ -275,12 +269,11 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
case MSG_TYPE_LABELMAPPING:
case MSG_TYPE_LABELREQUEST:
if (tlv_len != REQID_TLV_LEN) {
- session_shutdown(nbr, S_BAD_TLV_LEN,
- msg.id, msg.type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg.id, msg.type);
goto err;
}
- flags |= F_MAP_REQ_ID;
+ SET_FLAG(flags, F_MAP_REQ_ID);
memcpy(&reqbuf, buf, sizeof(reqbuf));
reqid = ntohl(reqbuf);
break;
@@ -299,8 +292,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
case MSG_TYPE_LABELWITHDRAW:
case MSG_TYPE_LABELRELEASE:
if (tlv_len != LABEL_TLV_LEN) {
- session_shutdown(nbr, S_BAD_TLV_LEN,
- msg.id, msg.type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg.id, msg.type);
goto err;
}
@@ -312,8 +304,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
label != MPLS_LABEL_IPV4_EXPLICIT_NULL &&
label != MPLS_LABEL_IPV6_EXPLICIT_NULL &&
label != MPLS_LABEL_IMPLICIT_NULL)) {
- session_shutdown(nbr, S_BAD_TLV_VAL,
- msg.id, msg.type);
+ session_shutdown(nbr, S_BAD_TLV_VAL, msg.id, msg.type);
goto err;
}
break;
@@ -329,8 +320,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
case MSG_TYPE_LABELWITHDRAW:
case MSG_TYPE_LABELRELEASE:
/* unsupported */
- session_shutdown(nbr, S_BAD_TLV_VAL, msg.id,
- msg.type);
+ session_shutdown(nbr, S_BAD_TLV_VAL, msg.id, msg.type);
goto err;
break;
default:
@@ -340,8 +330,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
break;
case TLV_TYPE_STATUS:
if (tlv_len != STATUS_TLV_LEN) {
- session_shutdown(nbr, S_BAD_TLV_LEN, msg.id,
- msg.type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg.id, msg.type);
goto err;
}
/* ignore */
@@ -350,12 +339,11 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
switch (type) {
case MSG_TYPE_LABELMAPPING:
if (tlv_len != PW_STATUS_TLV_LEN) {
- session_shutdown(nbr, S_BAD_TLV_LEN,
- msg.id, msg.type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg.id, msg.type);
goto err;
}
- flags |= F_MAP_PW_STATUS;
+ SET_FLAG(flags, F_MAP_PW_STATUS);
memcpy(&statusbuf, buf, sizeof(statusbuf));
pw_status = ntohl(statusbuf);
break;
@@ -365,7 +353,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
}
break;
default:
- if (!(ntohs(tlv.type) & UNKNOWN_FLAG))
+ if (!CHECK_FLAG(ntohs(tlv.type), UNKNOWN_FLAG))
send_notification_rtlvs(nbr, S_UNKNOWN_TLV,
msg.id, msg.type, tlv_type, tlv_len, buf);
/* ignore unknown tlv */
@@ -380,14 +368,13 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
while ((me = TAILQ_FIRST(&mh)) != NULL) {
int imsg_type = IMSG_NONE;
- me->map.flags |= flags;
+ SET_FLAG(me->map.flags, flags);
switch (me->map.type) {
case MAP_TYPE_PREFIX:
switch (me->map.fec.prefix.af) {
case AF_INET:
if (label == MPLS_LABEL_IPV6_EXPLICIT_NULL) {
- session_shutdown(nbr, S_BAD_TLV_VAL,
- msg.id, msg.type);
+ session_shutdown(nbr, S_BAD_TLV_VAL, msg.id, msg.type);
goto err;
}
if (!nbr->v4_enabled)
@@ -395,8 +382,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
break;
case AF_INET6:
if (label == MPLS_LABEL_IPV4_EXPLICIT_NULL) {
- session_shutdown(nbr, S_BAD_TLV_VAL,
- msg.id, msg.type);
+ session_shutdown(nbr, S_BAD_TLV_VAL, msg.id, msg.type);
goto err;
}
if (!nbr->v6_enabled)
@@ -408,18 +394,17 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
break;
case MAP_TYPE_PWID:
if (label <= MPLS_LABEL_RESERVED_MAX) {
- session_shutdown(nbr, S_BAD_TLV_VAL, msg.id,
- msg.type);
+ session_shutdown(nbr, S_BAD_TLV_VAL, msg.id, msg.type);
goto err;
}
- if (me->map.flags & F_MAP_PW_STATUS)
+ if (CHECK_FLAG(me->map.flags, F_MAP_PW_STATUS))
me->map.pw_status = pw_status;
break;
default:
break;
}
me->map.label = label;
- if (me->map.flags & F_MAP_REQ_ID)
+ if (CHECK_FLAG(me->map.flags, F_MAP_REQ_ID))
me->map.requestid = reqid;
log_msg_mapping(0, type, nbr, &me->map);
@@ -513,11 +498,11 @@ len_fec_tlv(struct map *map)
break;
case MAP_TYPE_PWID:
len += FEC_PWID_ELM_MIN_LEN;
- if (map->flags & F_MAP_PW_ID)
+ if (CHECK_FLAG(map->flags, F_MAP_PW_ID))
len += PW_STATUS_TLV_LEN;
- if (map->flags & F_MAP_PW_IFMTU)
+ if (CHECK_FLAG(map->flags, F_MAP_PW_IFMTU))
len += FEC_SUBTLV_IFMTU_SIZE;
- if (map->flags & F_MAP_PW_STATUS)
+ if (CHECK_FLAG(map->flags, F_MAP_PW_STATUS))
len += PW_STATUS_TLV_SIZE;
break;
case MAP_TYPE_TYPED_WCARD:
@@ -552,15 +537,15 @@ gen_fec_tlv(struct ibuf *buf, struct map *map)
switch (map->type) {
case MAP_TYPE_WILDCARD:
ft.length = htons(sizeof(uint8_t));
- err |= ibuf_add(buf, &ft, sizeof(ft));
- err |= ibuf_add(buf, &map->type, sizeof(map->type));
+ SET_FLAG(err, ibuf_add(buf, &ft, sizeof(ft)));
+ SET_FLAG(err, ibuf_add(buf, &map->type, sizeof(map->type)));
break;
case MAP_TYPE_PREFIX:
len = PREFIX_SIZE(map->fec.prefix.prefixlen);
ft.length = htons(sizeof(map->type) + sizeof(family) +
sizeof(map->fec.prefix.prefixlen) + len);
- err |= ibuf_add(buf, &ft, sizeof(ft));
- err |= ibuf_add(buf, &map->type, sizeof(map->type));
+ SET_FLAG(err, ibuf_add(buf, &ft, sizeof(ft)));
+ SET_FLAG(err, ibuf_add(buf, &map->type, sizeof(map->type)));
switch (map->fec.prefix.af) {
case AF_INET:
family = htons(AF_IPV4);
@@ -572,45 +557,45 @@ gen_fec_tlv(struct ibuf *buf, struct map *map)
fatalx("gen_fec_tlv: unknown af");
break;
}
- err |= ibuf_add(buf, &family, sizeof(family));
- err |= ibuf_add(buf, &map->fec.prefix.prefixlen,
- sizeof(map->fec.prefix.prefixlen));
+ SET_FLAG(err, ibuf_add(buf, &family, sizeof(family)));
+ SET_FLAG(err, ibuf_add(buf, &map->fec.prefix.prefixlen,
+ sizeof(map->fec.prefix.prefixlen)));
if (len)
- err |= ibuf_add(buf, &map->fec.prefix.prefix, len);
+ SET_FLAG(err, ibuf_add(buf, &map->fec.prefix.prefix, len));
break;
case MAP_TYPE_PWID:
- if (map->flags & F_MAP_PW_ID)
+ if (CHECK_FLAG(map->flags, F_MAP_PW_ID))
pw_len += FEC_PWID_SIZE;
- if (map->flags & F_MAP_PW_IFMTU)
+ if (CHECK_FLAG(map->flags, F_MAP_PW_IFMTU))
pw_len += FEC_SUBTLV_IFMTU_SIZE;
len = FEC_PWID_ELM_MIN_LEN + pw_len;
ft.length = htons(len);
- err |= ibuf_add(buf, &ft, sizeof(ft));
+ SET_FLAG(err, ibuf_add(buf, &ft, sizeof(ft)));
- err |= ibuf_add(buf, &map->type, sizeof(uint8_t));
+ SET_FLAG(err, ibuf_add(buf, &map->type, sizeof(uint8_t)));
pw_type = map->fec.pwid.type;
- if (map->flags & F_MAP_PW_CWORD)
- pw_type |= CONTROL_WORD_FLAG;
+ if (CHECK_FLAG(map->flags, F_MAP_PW_CWORD))
+ SET_FLAG(pw_type, CONTROL_WORD_FLAG);
pw_type = htons(pw_type);
- err |= ibuf_add(buf, &pw_type, sizeof(uint16_t));
- err |= ibuf_add(buf, &pw_len, sizeof(uint8_t));
+ SET_FLAG(err, ibuf_add(buf, &pw_type, sizeof(uint16_t)));
+ SET_FLAG(err, ibuf_add(buf, &pw_len, sizeof(uint8_t)));
group_id = htonl(map->fec.pwid.group_id);
- err |= ibuf_add(buf, &group_id, sizeof(uint32_t));
- if (map->flags & F_MAP_PW_ID) {
+ SET_FLAG(err, ibuf_add(buf, &group_id, sizeof(uint32_t)));
+ if (CHECK_FLAG(map->flags, F_MAP_PW_ID)) {
pwid = htonl(map->fec.pwid.pwid);
- err |= ibuf_add(buf, &pwid, sizeof(uint32_t));
+ SET_FLAG(err, ibuf_add(buf, &pwid, sizeof(uint32_t)));
}
- if (map->flags & F_MAP_PW_IFMTU) {
+ if (CHECK_FLAG(map->flags, F_MAP_PW_IFMTU)) {
struct subtlv stlv;
stlv.type = SUBTLV_IFMTU;
stlv.length = FEC_SUBTLV_IFMTU_SIZE;
- err |= ibuf_add(buf, &stlv, sizeof(uint16_t));
+ SET_FLAG(err, ibuf_add(buf, &stlv, sizeof(uint16_t)));
ifmtu = htons(map->fec.pwid.ifmtu);
- err |= ibuf_add(buf, &ifmtu, sizeof(uint16_t));
+ SET_FLAG(err, ibuf_add(buf, &ifmtu, sizeof(uint16_t)));
}
break;
case MAP_TYPE_TYPED_WCARD:
@@ -624,14 +609,14 @@ gen_fec_tlv(struct ibuf *buf, struct map *map)
fatalx("gen_fec_tlv: unexpected fec type");
}
ft.length = htons(len);
- err |= ibuf_add(buf, &ft, sizeof(ft));
- err |= ibuf_add(buf, &map->type, sizeof(uint8_t));
- err |= ibuf_add(buf, &map->fec.twcard.type, sizeof(uint8_t));
+ SET_FLAG(err, ibuf_add(buf, &ft, sizeof(ft)));
+ SET_FLAG(err, ibuf_add(buf, &map->type, sizeof(uint8_t)));
+ SET_FLAG(err, ibuf_add(buf, &map->fec.twcard.type, sizeof(uint8_t)));
switch (map->fec.twcard.type) {
case MAP_TYPE_PREFIX:
twcard_len = sizeof(uint16_t);
- err |= ibuf_add(buf, &twcard_len, sizeof(uint8_t));
+ SET_FLAG(err, ibuf_add(buf, &twcard_len, sizeof(uint8_t)));
switch (map->fec.twcard.u.prefix_af) {
case AF_INET:
@@ -645,13 +630,13 @@ gen_fec_tlv(struct ibuf *buf, struct map *map)
break;
}
- err |= ibuf_add(buf, &family, sizeof(uint16_t));
+ SET_FLAG(err, ibuf_add(buf, &family, sizeof(uint16_t)));
break;
case MAP_TYPE_PWID:
twcard_len = sizeof(uint16_t);
- err |= ibuf_add(buf, &twcard_len, sizeof(uint8_t));
+ SET_FLAG(err, ibuf_add(buf, &twcard_len, sizeof(uint8_t)));
pw_type = htons(map->fec.twcard.u.pw_type);
- err |= ibuf_add(buf, &pw_type, sizeof(uint16_t));
+ SET_FLAG(err, ibuf_add(buf, &pw_type, sizeof(uint16_t)));
break;
default:
fatalx("gen_fec_tlv: unexpected fec type");
@@ -679,21 +664,18 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf,
if (len == FEC_ELM_WCARD_LEN)
return (off);
else {
- session_shutdown(nbr, S_BAD_TLV_VAL, msg->id,
- msg->type);
+ session_shutdown(nbr, S_BAD_TLV_VAL, msg->id, msg->type);
return (-1);
}
break;
case MAP_TYPE_PREFIX:
if (len < FEC_ELM_PREFIX_MIN_LEN) {
- session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
- msg->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id, msg->type);
return (-1);
}
/* Address Family */
- memcpy(&map->fec.prefix.af, buf + off,
- sizeof(map->fec.prefix.af));
+ memcpy(&map->fec.prefix.af, buf + off, sizeof(map->fec.prefix.af));
off += sizeof(map->fec.prefix.af);
map->fec.prefix.af = ntohs(map->fec.prefix.af);
switch (map->fec.prefix.af) {
@@ -704,8 +686,7 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf,
map->fec.prefix.af = AF_INET6;
break;
default:
- send_notification(nbr->tcp, S_UNSUP_ADDR, msg->id,
- msg->type);
+ send_notification(nbr->tcp, S_UNSUP_ADDR, msg->id, msg->type);
return (-1);
}
@@ -716,19 +697,16 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf,
&& map->fec.prefix.prefixlen > IPV4_MAX_BITLEN)
|| (map->fec.prefix.af == AF_IPV6
&& map->fec.prefix.prefixlen > IPV6_MAX_BITLEN)) {
- session_shutdown(nbr, S_BAD_TLV_VAL, msg->id,
- msg->type);
+ session_shutdown(nbr, S_BAD_TLV_VAL, msg->id, msg->type);
return (-1);
}
if (len < off + PREFIX_SIZE(map->fec.prefix.prefixlen)) {
- session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
- msg->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id, msg->type);
return (-1);
}
/* Prefix */
- memset(&map->fec.prefix.prefix, 0,
- sizeof(map->fec.prefix.prefix));
+ memset(&map->fec.prefix.prefix, 0, sizeof(map->fec.prefix.prefix));
memcpy(&map->fec.prefix.prefix, buf + off,
PREFIX_SIZE(map->fec.prefix.prefixlen));
@@ -739,17 +717,16 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf,
return (off + PREFIX_SIZE(map->fec.prefix.prefixlen));
case MAP_TYPE_PWID:
if (len < FEC_PWID_ELM_MIN_LEN) {
- session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
- msg->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id, msg->type);
return (-1);
}
/* PW type */
memcpy(&map->fec.pwid.type, buf + off, sizeof(uint16_t));
map->fec.pwid.type = ntohs(map->fec.pwid.type);
- if (map->fec.pwid.type & CONTROL_WORD_FLAG) {
- map->flags |= F_MAP_PW_CWORD;
- map->fec.pwid.type &= ~CONTROL_WORD_FLAG;
+ if (CHECK_FLAG(map->fec.pwid.type, CONTROL_WORD_FLAG)) {
+ SET_FLAG(map->flags, F_MAP_PW_CWORD);
+ UNSET_FLAG(map->fec.pwid.type, CONTROL_WORD_FLAG);
}
off += sizeof(uint16_t);
@@ -758,8 +735,7 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf,
off += sizeof(uint8_t);
if (len != FEC_PWID_ELM_MIN_LEN + pw_len) {
- session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
- msg->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id, msg->type);
return (-1);
}
@@ -773,14 +749,13 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf,
return (off);
if (pw_len < sizeof(uint32_t)) {
- session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
- msg->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id, msg->type);
return (-1);
}
memcpy(&map->fec.pwid.pwid, buf + off, sizeof(uint32_t));
map->fec.pwid.pwid = ntohl(map->fec.pwid.pwid);
- map->flags |= F_MAP_PW_ID;
+ SET_FLAG(map->flags, F_MAP_PW_ID);
off += sizeof(uint32_t);
pw_len -= sizeof(uint32_t);
@@ -789,29 +764,26 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf,
struct subtlv stlv;
if (pw_len < sizeof(stlv)) {
- session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
- msg->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id, msg->type);
return (-1);
}
memcpy(&stlv, buf + off, sizeof(stlv));
if (stlv.length > pw_len) {
- session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
- msg->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id, msg->type);
return (-1);
}
switch (stlv.type) {
case SUBTLV_IFMTU:
if (stlv.length != FEC_SUBTLV_IFMTU_SIZE) {
- session_shutdown(nbr, S_BAD_TLV_LEN,
- msg->id, msg->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id, msg->type);
return (-1);
}
memcpy(&map->fec.pwid.ifmtu, buf + off +
SUBTLV_HDR_SIZE, sizeof(uint16_t));
map->fec.pwid.ifmtu = ntohs(map->fec.pwid.ifmtu);
- map->flags |= F_MAP_PW_IFMTU;
+ SET_FLAG(map->flags, F_MAP_PW_IFMTU);
break;
default:
/* ignore */
@@ -824,8 +796,7 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf,
return (off);
case MAP_TYPE_TYPED_WCARD:
if (len < FEC_ELM_TWCARD_MIN_LEN) {
- session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
- msg->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id, msg->type);
return (-1);
}
@@ -834,23 +805,19 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf,
memcpy(&twcard_len, buf + off, sizeof(uint8_t));
off += sizeof(uint8_t);
if (len != FEC_ELM_TWCARD_MIN_LEN + twcard_len) {
- session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
- msg->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id, msg->type);
return (-1);
}
switch (map->fec.twcard.type) {
case MAP_TYPE_PREFIX:
if (twcard_len != sizeof(uint16_t)) {
- session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
- msg->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id, msg->type);
return (-1);
}
- memcpy(&map->fec.twcard.u.prefix_af, buf + off,
- sizeof(uint16_t));
- map->fec.twcard.u.prefix_af =
- ntohs(map->fec.twcard.u.prefix_af);
+ memcpy(&map->fec.twcard.u.prefix_af, buf + off, sizeof(uint16_t));
+ map->fec.twcard.u.prefix_af = ntohs(map->fec.twcard.u.prefix_af);
off += sizeof(uint16_t);
switch (map->fec.twcard.u.prefix_af) {
@@ -861,29 +828,24 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf,
map->fec.twcard.u.prefix_af = AF_INET6;
break;
default:
- session_shutdown(nbr, S_BAD_TLV_VAL, msg->id,
- msg->type);
+ session_shutdown(nbr, S_BAD_TLV_VAL, msg->id, msg->type);
return (-1);
}
break;
case MAP_TYPE_PWID:
if (twcard_len != sizeof(uint16_t)) {
- session_shutdown(nbr, S_BAD_TLV_LEN, msg->id,
- msg->type);
+ session_shutdown(nbr, S_BAD_TLV_LEN, msg->id, msg->type);
return (-1);
}
- memcpy(&map->fec.twcard.u.pw_type, buf + off,
- sizeof(uint16_t));
- map->fec.twcard.u.pw_type =
- ntohs(map->fec.twcard.u.pw_type);
+ memcpy(&map->fec.twcard.u.pw_type, buf + off, sizeof(uint16_t));
+ map->fec.twcard.u.pw_type = ntohs(map->fec.twcard.u.pw_type);
/* ignore the reserved bit as per RFC 6667 */
map->fec.twcard.u.pw_type &= ~PW_TWCARD_RESERVED_BIT;
off += sizeof(uint16_t);
break;
default:
- send_notification(nbr->tcp, S_UNKNOWN_FEC, msg->id,
- msg->type);
+ send_notification(nbr->tcp, S_UNKNOWN_FEC, msg->id, msg->type);
return (-1);
}
diff --git a/ldpd/lde_lib.c b/ldpd/lde_lib.c
index 470580ff5e..04bff90158 100644
--- a/ldpd/lde_lib.c
+++ b/ldpd/lde_lib.c
@@ -17,17 +17,16 @@
#include "mpls.h"
static __inline int fec_compare(const struct fec *, const struct fec *);
-static int lde_nbr_is_nexthop(struct fec_node *,
- struct lde_nbr *);
-static void fec_free(void *);
-static struct fec_node *fec_add(struct fec *fec);
-static struct fec_nh *fec_nh_add(struct fec_node *, int, union ldpd_addr *,
+static int lde_nbr_is_nexthop(struct fec_node *, struct lde_nbr *);
+static void fec_free(void *);
+static struct fec_node *fec_add(struct fec *fec);
+static struct fec_nh *fec_nh_add(struct fec_node *, int, union ldpd_addr *,
ifindex_t, uint8_t, unsigned short);
-static void fec_nh_del(struct fec_nh *);
+static void fec_nh_del(struct fec_nh *);
RB_GENERATE(fec_tree, fec, entry, fec_compare)
-struct fec_tree ft = RB_INITIALIZER(&ft);
+struct fec_tree ft = RB_INITIALIZER(&ft);
struct event *gc_timer;
/* FEC tree functions */
@@ -47,11 +46,9 @@ fec_compare(const struct fec *a, const struct fec *b)
switch (a->type) {
case FEC_TYPE_IPV4:
- if (ntohl(a->u.ipv4.prefix.s_addr) <
- ntohl(b->u.ipv4.prefix.s_addr))
+ if (ntohl(a->u.ipv4.prefix.s_addr) < ntohl(b->u.ipv4.prefix.s_addr))
return (-1);
- if (ntohl(a->u.ipv4.prefix.s_addr) >
- ntohl(b->u.ipv4.prefix.s_addr))
+ if (ntohl(a->u.ipv4.prefix.s_addr) > ntohl(b->u.ipv4.prefix.s_addr))
return (1);
if (a->u.ipv4.prefixlen < b->u.ipv4.prefixlen)
return (-1);
@@ -79,11 +76,9 @@ fec_compare(const struct fec *a, const struct fec *b)
return (-1);
if (a->u.pwid.pwid > b->u.pwid.pwid)
return (1);
- if (ntohl(a->u.pwid.lsr_id.s_addr) <
- ntohl(b->u.pwid.lsr_id.s_addr))
+ if (ntohl(a->u.pwid.lsr_id.s_addr) < ntohl(b->u.pwid.lsr_id.s_addr))
return (-1);
- if (ntohl(a->u.pwid.lsr_id.s_addr) >
- ntohl(b->u.pwid.lsr_id.s_addr))
+ if (ntohl(a->u.pwid.lsr_id.s_addr) > ntohl(b->u.pwid.lsr_id.s_addr))
return (1);
return (0);
}
@@ -261,8 +256,7 @@ fec_add(struct fec *fec)
fn->pw_remote_status = PW_FORWARDING;
if (fec_insert(&ft, &fn->fec))
- log_warnx("failed to add %s to ft tree",
- log_fec(&fn->fec));
+ log_warnx("failed to add %s to ft tree", log_fec(&fn->fec));
return (fn);
}
@@ -338,14 +332,14 @@ lde_kernel_insert(struct fec *fec, int af, union ldpd_addr *nexthop,
* installing in kernel and sending to peer
*/
iface = if_lookup(ldeconf, ifindex);
- if ((ldeconf->flags & F_LDPD_ORDERED_CONTROL) &&
+ if (CHECK_FLAG(ldeconf->flags, F_LDPD_ORDERED_CONTROL) &&
!connected && iface != NULL && fec->type != FEC_TYPE_PWID)
- fnh->flags |= F_FEC_NH_DEFER;
+ SET_FLAG(fnh->flags, F_FEC_NH_DEFER);
}
- fnh->flags |= F_FEC_NH_NEW;
+ SET_FLAG(fnh->flags, F_FEC_NH_NEW);
if (connected)
- fnh->flags |= F_FEC_NH_CONNECTED;
+ SET_FLAG(fnh->flags, F_FEC_NH_CONNECTED);
}
void
@@ -388,22 +382,22 @@ lde_kernel_update(struct fec *fec)
return;
LIST_FOREACH_SAFE(fnh, &fn->nexthops, entry, safe) {
- if (fnh->flags & F_FEC_NH_NEW) {
- fnh->flags &= ~F_FEC_NH_NEW;
+ if (CHECK_FLAG(fnh->flags, F_FEC_NH_NEW)) {
+ UNSET_FLAG(fnh->flags, F_FEC_NH_NEW);
/*
* if LDP configured on interface or a static route
* clear flag else treat fec as a connected route
*/
- if (ldeconf->flags & F_LDPD_ENABLED) {
+ if (CHECK_FLAG(ldeconf->flags, F_LDPD_ENABLED)) {
iface = if_lookup(ldeconf,fnh->ifindex);
- if (fnh->flags & F_FEC_NH_CONNECTED ||
+ if (CHECK_FLAG(fnh->flags, F_FEC_NH_CONNECTED) ||
iface ||
fnh->route_type == ZEBRA_ROUTE_STATIC)
- fnh->flags &=~F_FEC_NH_NO_LDP;
+ UNSET_FLAG(fnh->flags, F_FEC_NH_NO_LDP);
else
- fnh->flags |= F_FEC_NH_NO_LDP;
+ SET_FLAG(fnh->flags, F_FEC_NH_NO_LDP);
} else
- fnh->flags |= F_FEC_NH_NO_LDP;
+ SET_FLAG(fnh->flags, F_FEC_NH_NO_LDP);
} else {
lde_send_delete_klabel(fn, fnh);
fec_nh_del(fnh);
@@ -510,7 +504,7 @@ lde_check_mapping(struct map *map, struct lde_nbr *ln, int rcvd_label_mapping)
/* RFC 4447 control word and status tlv negotiation */
if (map->type == MAP_TYPE_PWID && l2vpn_pw_negotiate(ln, fn, map)) {
- if (rcvd_label_mapping && map->flags & F_MAP_PW_STATUS)
+ if (rcvd_label_mapping && CHECK_FLAG(map->flags, F_MAP_PW_STATUS))
fn->pw_remote_status = map->pw_status;
return;
@@ -534,8 +528,7 @@ lde_check_mapping(struct map *map, struct lde_nbr *ln, int rcvd_label_mapping)
* the possibility of multipath.
*/
LIST_FOREACH(fnh, &fn->nexthops, entry) {
- if (lde_address_find(ln, fnh->af,
- &fnh->nexthop) == NULL)
+ if (lde_address_find(ln, fnh->af, &fnh->nexthop) == NULL)
continue;
lde_send_delete_klabel(fn, fnh);
@@ -561,9 +554,9 @@ lde_check_mapping(struct map *map, struct lde_nbr *ln, int rcvd_label_mapping)
* NH so clear flag and send labelmap msg to
* peer
*/
- if (ldeconf->flags & F_LDPD_ORDERED_CONTROL) {
+ if (CHECK_FLAG(ldeconf->flags, F_LDPD_ORDERED_CONTROL)) {
send_map = true;
- fnh->flags &= ~F_FEC_NH_DEFER;
+ UNSET_FLAG(fnh->flags, F_FEC_NH_DEFER);
}
fnh->remote_label = map->label;
if (fn->local_label != NO_LABEL)
@@ -575,9 +568,9 @@ lde_check_mapping(struct map *map, struct lde_nbr *ln, int rcvd_label_mapping)
continue;
pw->remote_group = map->fec.pwid.group_id;
- if (map->flags & F_MAP_PW_IFMTU)
+ if (CHECK_FLAG(map->flags, F_MAP_PW_IFMTU))
pw->remote_mtu = map->fec.pwid.ifmtu;
- if (rcvd_label_mapping && map->flags & F_MAP_PW_STATUS) {
+ if (rcvd_label_mapping && CHECK_FLAG(map->flags, F_MAP_PW_STATUS)) {
pw->remote_status = map->pw_status;
fn->pw_remote_status = map->pw_status;
}
@@ -726,7 +719,7 @@ lde_check_release(struct map *map, struct lde_nbr *ln)
/* wildcard label release */
if (map->type == MAP_TYPE_WILDCARD ||
map->type == MAP_TYPE_TYPED_WCARD ||
- (map->type == MAP_TYPE_PWID && !(map->flags & F_MAP_PW_ID))) {
+ (map->type == MAP_TYPE_PWID && !CHECK_FLAG(map->flags, F_MAP_PW_ID))) {
lde_check_release_wcard(map, ln);
return;
}
@@ -818,7 +811,7 @@ lde_check_withdraw(struct map *map, struct lde_nbr *ln)
/* wildcard label withdraw */
if (map->type == MAP_TYPE_WILDCARD ||
map->type == MAP_TYPE_TYPED_WCARD ||
- (map->type == MAP_TYPE_PWID && !(map->flags & F_MAP_PW_ID))) {
+ (map->type == MAP_TYPE_PWID && !CHECK_FLAG(map->flags, F_MAP_PW_ID))) {
lde_check_withdraw_wcard(map, ln);
return;
}
@@ -868,15 +861,14 @@ lde_check_withdraw(struct map *map, struct lde_nbr *ln)
return;
/* Ordered Control: additional withdraw steps */
- if (ldeconf->flags & F_LDPD_ORDERED_CONTROL) {
+ if (CHECK_FLAG(ldeconf->flags, F_LDPD_ORDERED_CONTROL)) {
/* LWd.8: for each neighbor other that src of withdraw msg */
RB_FOREACH(lnbr, nbr_tree, &lde_nbrs) {
if (ln->peerid == lnbr->peerid)
continue;
/* LWd.9: check if previously sent a label mapping */
- me = (struct lde_map *)fec_find(&lnbr->sent_map,
- &fn->fec);
+ me = (struct lde_map *)fec_find(&lnbr->sent_map, &fn->fec);
/*
* LWd.10: does label sent to peer "map" to withdraw
@@ -915,8 +907,7 @@ lde_check_withdraw_wcard(struct map *map, struct lde_nbr *ln)
switch (f->type) {
case FEC_TYPE_IPV4:
case FEC_TYPE_IPV6:
- if (!lde_address_find(ln, fnh->af,
- &fnh->nexthop))
+ if (!lde_address_find(ln, fnh->af, &fnh->nexthop))
continue;
break;
case FEC_TYPE_PWID:
@@ -929,8 +920,7 @@ lde_check_withdraw_wcard(struct map *map, struct lde_nbr *ln)
default:
break;
}
- if (map->label != NO_LABEL && map->label !=
- fnh->remote_label)
+ if (map->label != NO_LABEL && map->label != fnh->remote_label)
continue;
lde_send_delete_klabel(fn, fnh);
@@ -941,8 +931,7 @@ lde_check_withdraw_wcard(struct map *map, struct lde_nbr *ln)
lde_rlfa_update_clients(f, ln, MPLS_INVALID_LABEL);
/* LWd.3: check previously received label mapping */
- if (me && (map->label == NO_LABEL ||
- map->label == me->map.label))
+ if (me && (map->label == NO_LABEL || map->label == me->map.label))
/*
* LWd.4: remove record of previously received
* label mapping
@@ -953,7 +942,7 @@ lde_check_withdraw_wcard(struct map *map, struct lde_nbr *ln)
continue;
/* Ordered Control: additional withdraw steps */
- if (ldeconf->flags & F_LDPD_ORDERED_CONTROL) {
+ if (CHECK_FLAG(ldeconf->flags, F_LDPD_ORDERED_CONTROL)) {
/*
* LWd.8: for each neighbor other that src of
* withdraw msg
@@ -965,16 +954,14 @@ lde_check_withdraw_wcard(struct map *map, struct lde_nbr *ln)
/* LWd.9: check if previously sent a label
* mapping
*/
- me = (struct lde_map *)fec_find(
- &lnbr->sent_map, &fn->fec);
+ me = (struct lde_map *)fec_find(&lnbr->sent_map, &fn->fec);
/*
* LWd.10: does label sent to peer "map" to
* withdraw label
*/
if (me && lde_nbr_is_nexthop(fn, lnbr))
/* LWd.11: send label withdraw */
- lde_send_labelwithdraw(lnbr, fn, NULL,
- NULL);
+ lde_send_labelwithdraw(lnbr, fn, NULL, NULL);
}
}
}
diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c
index d3193b16d7..e66b9e92dd 100644
--- a/ldpd/ldpe.c
+++ b/ldpd/ldpe.c
@@ -257,8 +257,7 @@ ldpe_imsg_compose_lde(int type, uint32_t peerid, pid_t pid, void *data,
{
if (iev_lde->ibuf.fd == -1)
return (0);
- return (imsg_compose_event(iev_lde, type, peerid, pid, -1,
- data, datalen));
+ return (imsg_compose_event(iev_lde, type, peerid, pid, -1, data, datalen));
}
/* ARGSUSED */
@@ -309,8 +308,7 @@ static void ldpe_dispatch_main(struct event *thread)
switch (imsg.hdr.type) {
case IMSG_IFSTATUS:
- if (imsg.hdr.len != IMSG_HEADER_SIZE +
- sizeof(struct kif))
+ if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(struct kif))
fatalx("IFSTATUS imsg with wrong len");
kif = imsg.data;
@@ -336,15 +334,13 @@ static void ldpe_dispatch_main(struct event *thread)
}
break;
case IMSG_NEWADDR:
- if (imsg.hdr.len != IMSG_HEADER_SIZE +
- sizeof(struct kaddr))
+ if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(struct kaddr))
fatalx("NEWADDR imsg with wrong len");
if_addr_add(imsg.data);
break;
case IMSG_DELADDR:
- if (imsg.hdr.len != IMSG_HEADER_SIZE +
- sizeof(struct kaddr))
+ if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(struct kaddr))
fatalx("DELADDR imsg with wrong len");
if_addr_del(imsg.data);
@@ -369,8 +365,7 @@ static void ldpe_dispatch_main(struct event *thread)
iev_lde->ev_write = NULL;
break;
case IMSG_INIT:
- if (imsg.hdr.len != IMSG_HEADER_SIZE +
- sizeof(struct ldpd_init))
+ if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(struct ldpd_init))
fatalx("INIT imsg with wrong len");
memcpy(&init, imsg.data, sizeof(init));
@@ -398,14 +393,11 @@ static void ldpe_dispatch_main(struct event *thread)
disc_socket = -1;
edisc_socket = -1;
session_socket = -1;
- if ((ldp_af_conf_get(leconf, af))->flags &
- F_LDPD_AF_ENABLED)
- ldpe_imsg_compose_parent(IMSG_REQUEST_SOCKETS,
- af, NULL, 0);
+ if (CHECK_FLAG((ldp_af_conf_get(leconf, af))->flags, F_LDPD_AF_ENABLED))
+ ldpe_imsg_compose_parent(IMSG_REQUEST_SOCKETS, af, NULL, 0);
break;
case IMSG_SOCKET_NET:
- if (imsg.hdr.len != IMSG_HEADER_SIZE +
- sizeof(enum socket_type))
+ if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(enum socket_type))
fatalx("SOCKET_NET imsg with wrong len");
socket_type = imsg.data;
@@ -434,15 +426,13 @@ static void ldpe_dispatch_main(struct event *thread)
break;
}
- ldpe_setup_sockets(af, disc_socket, edisc_socket,
- session_socket);
+ ldpe_setup_sockets(af, disc_socket, edisc_socket, session_socket);
if_update_all(af);
tnbr_update_all(af);
RB_FOREACH(nbr, nbr_id_head, &nbrs_by_id) {
if (nbr->af != af)
continue;
- nbr->laddr = (ldp_af_conf_get(leconf,
- af))->trans_addr;
+ nbr->laddr = (ldp_af_conf_get(leconf, af))->trans_addr;
#ifdef __OpenBSD__
nbrp = nbr_params_find(leconf, nbr->id);
if (nbrp) {
@@ -456,8 +446,7 @@ static void ldpe_dispatch_main(struct event *thread)
}
break;
case IMSG_RTRID_UPDATE:
- memcpy(&global.rtr_id, imsg.data,
- sizeof(global.rtr_id));
+ memcpy(&global.rtr_id, imsg.data, sizeof(global.rtr_id));
if (leconf->rtr_id.s_addr == INADDR_ANY) {
ldpe_reset_nbrs(AF_UNSPEC);
}
@@ -465,8 +454,7 @@ static void ldpe_dispatch_main(struct event *thread)
tnbr_update_all(AF_UNSPEC);
break;
case IMSG_RECONF_CONF:
- if ((nconf = malloc(sizeof(struct ldpd_conf))) ==
- NULL)
+ if ((nconf = malloc(sizeof(struct ldpd_conf))) == NULL)
fatal(NULL);
memcpy(nconf, imsg.data, sizeof(struct ldpd_conf));
@@ -546,16 +534,13 @@ static void ldpe_dispatch_main(struct event *thread)
memcpy(&ldp_debug, imsg.data, sizeof(ldp_debug));
break;
case IMSG_FILTER_UPDATE:
- if (imsg.hdr.len != IMSG_HEADER_SIZE +
- sizeof(struct ldp_access)) {
+ if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(struct ldp_access)) {
log_warnx("%s: wrong imsg len", __func__);
break;
}
laccess = imsg.data;
- ldpe_check_filter_af(AF_INET, &leconf->ipv4,
- laccess->name);
- ldpe_check_filter_af(AF_INET6, &leconf->ipv6,
- laccess->name);
+ ldpe_check_filter_af(AF_INET, &leconf->ipv4, laccess->name);
+ ldpe_check_filter_af(AF_INET6, &leconf->ipv6, laccess->name);
break;
case IMSG_LDP_SYNC_IF_STATE_REQUEST:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
@@ -605,8 +590,7 @@ static void ldpe_dispatch_main(struct event *thread)
}
break;
default:
- log_debug("%s: error handling imsg %d",
- __func__, imsg.hdr.type);
+ log_debug("%s: error handling imsg %d", __func__, imsg.hdr.type);
break;
}
imsg_free(&imsg);
@@ -650,8 +634,7 @@ static void ldpe_dispatch_lde(struct event *thread)
case IMSG_RELEASE_ADD:
case IMSG_REQUEST_ADD:
case IMSG_WITHDRAW_ADD:
- if (imsg.hdr.len - IMSG_HEADER_SIZE !=
- sizeof(struct map))
+ if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(struct map))
fatalx("invalid size of map request");
map = imsg.data;
@@ -706,8 +689,7 @@ static void ldpe_dispatch_lde(struct event *thread)
}
break;
case IMSG_NOTIFICATION_SEND:
- if (imsg.hdr.len - IMSG_HEADER_SIZE !=
- sizeof(struct notify_msg))
+ if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(struct notify_msg))
fatalx("invalid size of OE request");
nm = imsg.data;
@@ -741,8 +723,7 @@ static void ldpe_dispatch_lde(struct event *thread)
session_shutdown(nbr,S_SHUTDOWN,0,0);
break;
default:
- log_debug("%s: error handling imsg %d",
- __func__, imsg.hdr.type);
+ log_debug("%s: error handling imsg %d", __func__, imsg.hdr.type);
break;
}
imsg_free(&imsg);
@@ -860,7 +841,7 @@ ldpe_remove_dynamic_tnbrs(int af)
if (tnbr->af != af)
continue;
- tnbr->flags &= ~F_TNBR_DYNAMIC;
+ UNSET_FLAG(tnbr->flags, F_TNBR_DYNAMIC);
tnbr_check(leconf, tnbr);
}
}
diff --git a/ldpd/neighbor.c b/ldpd/neighbor.c
index 6f9177fe8b..5209c55bb8 100644
--- a/ldpd/neighbor.c
+++ b/ldpd/neighbor.c
@@ -19,10 +19,8 @@ DEFINE_HOOK(ldp_nbr_state_change, (struct nbr * nbr, int old_state),
(nbr, old_state));
static __inline int nbr_id_compare(const struct nbr *, const struct nbr *);
-static __inline int nbr_addr_compare(const struct nbr *,
- const struct nbr *);
-static __inline int nbr_pid_compare(const struct nbr *,
- const struct nbr *);
+static __inline int nbr_addr_compare(const struct nbr *, const struct nbr *);
+static __inline int nbr_pid_compare(const struct nbr *, const struct nbr *);
static void nbr_update_peerid(struct nbr *);
static void nbr_ktimer(struct event *thread);
static void nbr_start_ktimer(struct nbr *);
@@ -127,7 +125,7 @@ nbr_fsm(struct nbr *nbr, enum nbr_event event)
old_state = nbr->state;
for (i = 0; nbr_fsm_tbl[i].state != -1; i++)
- if ((nbr_fsm_tbl[i].state & old_state) &&
+ if (CHECK_FLAG(nbr_fsm_tbl[i].state, old_state) &&
(nbr_fsm_tbl[i].event == event)) {
new_state = nbr_fsm_tbl[i].new_state;
break;
@@ -196,8 +194,7 @@ nbr_fsm(struct nbr *nbr, enum nbr_event event)
send_keepalive(nbr);
break;
case NBR_ACT_CLOSE_SESSION:
- ldpe_imsg_compose_lde(IMSG_NEIGHBOR_DOWN, nbr->peerid, 0,
- NULL, 0);
+ ldpe_imsg_compose_lde(IMSG_NEIGHBOR_DOWN, nbr->peerid, 0, NULL, 0);
session_close(nbr);
break;
case NBR_ACT_NOTHING:
@@ -606,8 +603,7 @@ nbr_establish_connection(struct nbr *nbr)
return (-1);
}
#else
- sock_set_md5sig(nbr->fd, nbr->af, &nbr->raddr,
- nbrp->auth.md5key);
+ sock_set_md5sig(nbr->fd, nbr->af, &nbr->raddr, nbrp->auth.md5key);
#endif
}
@@ -646,8 +642,7 @@ nbr_establish_connection(struct nbr *nbr)
send_hello(adj->source.type, adj->source.link.ia,
adj->source.target);
- if (connect(nbr->fd, &remote_su.sa, sockaddr_len(&remote_su.sa))
- == -1) {
+ if (connect(nbr->fd, &remote_su.sa, sockaddr_len(&remote_su.sa)) == -1) {
if (errno == EINPROGRESS) {
event_add_write(master, nbr_connect_cb, nbr, nbr->fd,
&nbr->ev_connect);
@@ -674,14 +669,14 @@ nbr_gtsm_enabled(struct nbr *nbr, struct nbr_params *nbrp)
* statically (e.g., via configuration) and/or dynamically override the
* default behavior and enable/disable GTSM on a per-peer basis".
*/
- if (nbrp && (nbrp->flags & F_NBRP_GTSM))
+ if (nbrp && CHECK_FLAG(nbrp->flags, F_NBRP_GTSM))
return (nbrp->gtsm_enabled);
- if ((ldp_af_conf_get(leconf, nbr->af))->flags & F_LDPD_AF_NO_GTSM)
+ if (CHECK_FLAG((ldp_af_conf_get(leconf, nbr->af))->flags, F_LDPD_AF_NO_GTSM))
return (0);
/* By default, GTSM support has to be negotiated for LDPv4 */
- if (nbr->af == AF_INET && !(nbr->flags & F_NBR_GTSM_NEGOTIATED))
+ if (nbr->af == AF_INET && !CHECK_FLAG(nbr->flags, F_NBR_GTSM_NEGOTIATED))
return (0);
return (1);
@@ -692,7 +687,7 @@ nbr_gtsm_setup(int fd, int af, struct nbr_params *nbrp)
{
int ttl = 255;
- if (nbrp && (nbrp->flags & F_NBRP_GTSM_HOPS))
+ if (nbrp && CHECK_FLAG(nbrp->flags, F_NBRP_GTSM_HOPS))
ttl = 256 - nbrp->gtsm_hops;
switch (af) {
@@ -740,8 +735,7 @@ nbr_gtsm_check(int fd, struct nbr *nbr, struct nbr_params *nbrp)
}
if (nbr_gtsm_setup(fd, nbr->af, nbrp) == -1) {
- log_warnx("%s: error enabling GTSM for lsr-id %pI4", __func__,
- &nbr->id);
+ log_warnx("%s: error enabling GTSM for lsr-id %pI4", __func__, &nbr->id);
return (-1);
}
@@ -772,8 +766,7 @@ nbr_act_session_operational(struct nbr *nbr)
static void
nbr_send_labelmappings(struct nbr *nbr)
{
- ldpe_imsg_compose_lde(IMSG_LABEL_MAPPING_FULL, nbr->peerid, 0,
- NULL, 0);
+ ldpe_imsg_compose_lde(IMSG_LABEL_MAPPING_FULL, nbr->peerid, 0, NULL, 0);
}
static __inline int
@@ -810,7 +803,7 @@ nbr_get_keepalive(int af, struct in_addr lsr_id)
struct nbr_params *nbrp;
nbrp = nbr_params_find(leconf, lsr_id);
- if (nbrp && (nbrp->flags & F_NBRP_KEEPALIVE))
+ if (nbrp && CHECK_FLAG(nbrp->flags, F_NBRP_KEEPALIVE))
return (nbrp->keepalive);
return ((ldp_af_conf_get(leconf, af))->keepalive);
@@ -834,8 +827,7 @@ nbr_to_ctl(struct nbr *nbr)
nctl.stats = nbr->stats;
nctl.flags = nbr->flags;
nctl.max_pdu_len = nbr->max_pdu_len;
- nctl.hold_time_remaining =
- event_timer_remain_second(nbr->keepalive_timer);
+ nctl.hold_time_remaining = event_timer_remain_second(nbr->keepalive_timer);
gettimeofday(&now, NULL);
if (nbr->state == NBR_STA_OPER) {
diff --git a/lib/command.c b/lib/command.c
index 27cd3a04bd..7a7ce3f5dc 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -1303,6 +1303,14 @@ int config_from_file(struct vty *vty, FILE *fp, unsigned int *line_num)
while (fgets(vty->buf, VTY_BUFSIZ, fp)) {
++(*line_num);
+ if (vty_log_commands) {
+ int len = strlen(vty->buf);
+
+ /* now log the command */
+ zlog_notice("config-from-file# %.*s", len ? len - 1 : 0,
+ vty->buf);
+ }
+
ret = command_config_read_one_line(vty, NULL, *line_num, 0);
if (ret != CMD_SUCCESS && ret != CMD_WARNING
diff --git a/lib/vty.c b/lib/vty.c
index c6134fe07f..d6a0dba206 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -125,8 +125,8 @@ static int no_password_check = 0;
/* Integrated configuration file path */
static char integrate_default[] = SYSCONFDIR INTEGRATE_DEFAULT_CONFIG;
-static bool do_log_commands;
-static bool do_log_commands_perm;
+bool vty_log_commands;
+static bool vty_log_commands_perm;
void vty_mgmt_resume_response(struct vty *vty, bool success)
{
@@ -508,7 +508,7 @@ static int vty_command(struct vty *vty, char *buf)
/*
* Log non empty command lines
*/
- if (do_log_commands &&
+ if (vty_log_commands &&
strncmp(buf, "echo PING", strlen("echo PING")) != 0)
cp = buf;
if (cp != NULL) {
@@ -3160,15 +3160,15 @@ DEFPY (log_commands,
"Log all commands\n")
{
if (no) {
- if (do_log_commands_perm) {
+ if (vty_log_commands_perm) {
vty_out(vty,
"Daemon started with permanent logging turned on for commands, ignoring\n");
return CMD_WARNING;
}
- do_log_commands = false;
+ vty_log_commands = false;
} else
- do_log_commands = true;
+ vty_log_commands = true;
return CMD_SUCCESS;
}
@@ -3196,7 +3196,7 @@ static int vty_config_write(struct vty *vty)
vty_endframe(vty, "exit\n");
- if (do_log_commands)
+ if (vty_log_commands)
vty_out(vty, "log commands\n");
vty_out(vty, "!\n");
@@ -3677,8 +3677,8 @@ void vty_init(struct event_loop *master_thread, bool do_command_logging)
install_element(CONFIG_NODE, &log_commands_cmd);
if (do_command_logging) {
- do_log_commands = true;
- do_log_commands_perm = true;
+ vty_log_commands = true;
+ vty_log_commands_perm = true;
}
install_element(ENABLE_NODE, &terminal_monitor_cmd);
diff --git a/lib/vty.h b/lib/vty.h
index 5114238f6a..560748d91d 100644
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -335,6 +335,7 @@ struct vty_arg {
#endif
extern struct nb_config *vty_mgmt_candidate_config;
+extern bool vty_log_commands;
/* Prototypes. */
extern void vty_init(struct event_loop *m, bool do_command_logging);
diff --git a/tests/topotests/ospf_metric_propagation/r1/show_ip_route-1.json b/tests/topotests/ospf_metric_propagation/r1/show_ip_route-1.json
index e3a5cc410f..4f1ced81fb 100644
--- a/tests/topotests/ospf_metric_propagation/r1/show_ip_route-1.json
+++ b/tests/topotests/ospf_metric_propagation/r1/show_ip_route-1.json
@@ -4,7 +4,6 @@
"prefix":"10.0.94.0/24",
"prefixLen":24,
"protocol":"bgp",
- "vrfId":9,
"vrfName":"green",
"selected":true,
"destSelected":true,
@@ -25,7 +24,6 @@
"fib":true,
"ip":"10.0.10.5",
"afi":"ipv4",
- "interfaceIndex":6,
"interfaceName":"r1-eth1",
"vrf":"blue",
"active":true,
diff --git a/tests/topotests/ospf_metric_propagation/r1/show_ip_route-2.json b/tests/topotests/ospf_metric_propagation/r1/show_ip_route-2.json
index f3597bf458..882d3ca4f0 100644
--- a/tests/topotests/ospf_metric_propagation/r1/show_ip_route-2.json
+++ b/tests/topotests/ospf_metric_propagation/r1/show_ip_route-2.json
@@ -4,7 +4,6 @@
"prefix":"10.0.94.0/24",
"prefixLen":24,
"protocol":"bgp",
- "vrfId":9,
"vrfName":"green",
"selected":true,
"destSelected":true,
@@ -25,7 +24,6 @@
"fib":true,
"ip":"10.0.1.2",
"afi":"ipv4",
- "interfaceIndex":5,
"interfaceName":"r1-eth0",
"vrf":"default",
"active":true,
diff --git a/tests/topotests/ospf_metric_propagation/r1/show_ip_route-3.json b/tests/topotests/ospf_metric_propagation/r1/show_ip_route-3.json
index eebcab83e4..cd528459ab 100644
--- a/tests/topotests/ospf_metric_propagation/r1/show_ip_route-3.json
+++ b/tests/topotests/ospf_metric_propagation/r1/show_ip_route-3.json
@@ -4,7 +4,6 @@
"prefix":"10.0.94.0/24",
"prefixLen":24,
"protocol":"bgp",
- "vrfId":9,
"vrfName":"green",
"selected":true,
"destSelected":true,
@@ -25,7 +24,6 @@
"fib":true,
"ip":"10.0.1.2",
"afi":"ipv4",
- "interfaceIndex":5,
"interfaceName":"r1-eth0",
"vrf":"default",
"active":true,
diff --git a/tests/topotests/ospf_metric_propagation/r1/show_ip_route-4.json b/tests/topotests/ospf_metric_propagation/r1/show_ip_route-4.json
index d0e3d816d3..133f37549e 100644
--- a/tests/topotests/ospf_metric_propagation/r1/show_ip_route-4.json
+++ b/tests/topotests/ospf_metric_propagation/r1/show_ip_route-4.json
@@ -4,7 +4,6 @@
"prefix":"10.0.94.0/24",
"prefixLen":24,
"protocol":"bgp",
- "vrfId":9,
"vrfName":"green",
"selected":true,
"destSelected":true,
@@ -25,7 +24,6 @@
"fib":true,
"ip":"10.0.1.2",
"afi":"ipv4",
- "interfaceIndex":5,
"interfaceName":"r1-eth0",
"vrf":"default",
"active":true,
diff --git a/tests/topotests/ospf_metric_propagation/r1/show_ip_route-5.json b/tests/topotests/ospf_metric_propagation/r1/show_ip_route-5.json
index 989ccf7798..5d80509021 100644
--- a/tests/topotests/ospf_metric_propagation/r1/show_ip_route-5.json
+++ b/tests/topotests/ospf_metric_propagation/r1/show_ip_route-5.json
@@ -4,7 +4,6 @@
"prefix":"10.0.94.0/24",
"prefixLen":24,
"protocol":"bgp",
- "vrfId":9,
"vrfName":"green",
"selected":true,
"destSelected":true,
@@ -25,7 +24,6 @@
"fib":true,
"ip":"10.0.1.2",
"afi":"ipv4",
- "interfaceIndex":5,
"interfaceName":"r1-eth0",
"vrf":"default",
"active":true,
diff --git a/tests/topotests/ospf_metric_propagation/r1/show_ip_route-6.json b/tests/topotests/ospf_metric_propagation/r1/show_ip_route-6.json
index 84b11886e4..1b59707b98 100644
--- a/tests/topotests/ospf_metric_propagation/r1/show_ip_route-6.json
+++ b/tests/topotests/ospf_metric_propagation/r1/show_ip_route-6.json
@@ -4,7 +4,6 @@
"prefix":"10.0.94.0/24",
"prefixLen":24,
"protocol":"bgp",
- "vrfId":9,
"vrfName":"green",
"selected":true,
"destSelected":true,
@@ -25,7 +24,6 @@
"fib":true,
"ip":"10.0.10.5",
"afi":"ipv4",
- "interfaceIndex":6,
"interfaceName":"r1-eth1",
"vrf":"blue",
"active":true,
diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c
index f6c1fdd78e..a3b61c9049 100644
--- a/zebra/zebra_dplane.c
+++ b/zebra/zebra_dplane.c
@@ -3785,18 +3785,12 @@ tc_qdisc_update_internal(enum dplane_op_e op,
/* Obtain context block */
ctx = dplane_ctx_alloc();
- if (!ctx) {
- ret = ENOMEM;
- goto done;
- }
-
/* Init context with info from zebra data structs */
ret = dplane_ctx_tc_qdisc_init(ctx, op, qdisc);
if (ret == AOK)
ret = dplane_update_enqueue(ctx);
-done:
/* Update counter */
atomic_fetch_add_explicit(&zdplane_info.dg_tcs_in, 1,
memory_order_relaxed);
@@ -3822,18 +3816,12 @@ tc_class_update_internal(enum dplane_op_e op, struct zebra_tc_class *class)
/* Obtain context block */
ctx = dplane_ctx_alloc();
- if (!ctx) {
- ret = ENOMEM;
- goto done;
- }
-
/* Init context with info from zebra data structs */
ret = dplane_ctx_tc_class_init(ctx, op, class);
if (ret == AOK)
ret = dplane_update_enqueue(ctx);
-done:
/* Update counter */
atomic_fetch_add_explicit(&zdplane_info.dg_tcs_in, 1,
memory_order_relaxed);
@@ -3859,18 +3847,12 @@ tc_filter_update_internal(enum dplane_op_e op, struct zebra_tc_filter *filter)
/* Obtain context block */
ctx = dplane_ctx_alloc();
- if (!ctx) {
- ret = ENOMEM;
- goto done;
- }
-
/* Init context with info from zebra data structs */
ret = dplane_ctx_tc_filter_init(ctx, op, filter);
if (ret == AOK)
ret = dplane_update_enqueue(ctx);
-done:
/* Update counter */
atomic_fetch_add_explicit(&zdplane_info.dg_tcs_in, 1,
memory_order_relaxed);
@@ -3943,16 +3925,11 @@ dplane_nexthop_update_internal(struct nhg_hash_entry *nhe, enum dplane_op_e op)
/* Obtain context block */
ctx = dplane_ctx_alloc();
- if (!ctx) {
- ret = ENOMEM;
- goto done;
- }
ret = dplane_ctx_nexthop_init(ctx, op, nhe);
if (ret == AOK)
ret = dplane_update_enqueue(ctx);
-done:
/* Update counter */
atomic_fetch_add_explicit(&zdplane_info.dg_nexthops_in, 1,
memory_order_relaxed);
@@ -4083,8 +4060,6 @@ dplane_route_notif_update(struct route_node *rn,
goto done;
new_ctx = dplane_ctx_alloc();
- if (new_ctx == NULL)
- goto done;
/* Init context with info from zebra data structs */
dplane_ctx_route_init(new_ctx, op, rn, re);
@@ -4216,10 +4191,6 @@ dplane_lsp_notif_update(struct zebra_lsp *lsp, enum dplane_op_e op,
/* Obtain context block */
ctx = dplane_ctx_alloc();
- if (ctx == NULL) {
- ret = ENOMEM;
- goto done;
- }
/* Copy info from zebra LSP */
ret = dplane_ctx_lsp_init(ctx, op, lsp);
@@ -4589,16 +4560,11 @@ dplane_intf_update_internal(const struct interface *ifp, enum dplane_op_e op)
/* Obtain context block */
ctx = dplane_ctx_alloc();
- if (!ctx) {
- ret = ENOMEM;
- goto done;
- }
ret = dplane_ctx_intf_init(ctx, op, ifp);
if (ret == AOK)
ret = dplane_update_enqueue(ctx);
-done:
/* Update counter */
atomic_fetch_add_explicit(&zdplane_info.dg_intfs_in, 1,
memory_order_relaxed);
@@ -5337,8 +5303,10 @@ dplane_gre_set(struct interface *ifp, struct interface *ifp_link,
ctx = dplane_ctx_alloc();
- if (!ifp)
- return result;
+ if (!ifp) {
+ ret = EINVAL;
+ goto done;
+ }
if (IS_ZEBRA_DEBUG_DPLANE_DETAIL) {
zlog_debug("init dplane ctx %s: if %s link %s%s",
@@ -5350,8 +5318,11 @@ dplane_gre_set(struct interface *ifp, struct interface *ifp_link,
ctx->zd_op = op;
ctx->zd_status = ZEBRA_DPLANE_REQUEST_SUCCESS;
zns = zebra_ns_lookup(ifp->vrf->vrf_id);
- if (!zns)
- return result;
+ if (!zns) {
+ ret = EINVAL;
+ goto done;
+ }
+
dplane_ctx_ns_init(ctx, zns, false);
dplane_ctx_set_ifname(ctx, ifp->name);
@@ -5370,6 +5341,7 @@ dplane_gre_set(struct interface *ifp, struct interface *ifp_link,
/* Enqueue context for processing */
ret = dplane_update_enqueue(ctx);
+done:
/* Update counter */
atomic_fetch_add_explicit(&zdplane_info.dg_gre_set_in, 1,
memory_order_relaxed);