mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-11 15:18:06 +00:00
zebra: changes for code maintainability
these changes are for improving the code maintainability and readability Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
This commit is contained in:
parent
2501c3a4dc
commit
2df51c7fe3
@ -83,7 +83,7 @@ zebra_neigh_new(ifindex_t ifindex, struct ipaddr *ip, struct ethaddr *mac)
|
|||||||
n->ifindex = ifindex;
|
n->ifindex = ifindex;
|
||||||
if (mac) {
|
if (mac) {
|
||||||
memcpy(&n->mac, mac, sizeof(*mac));
|
memcpy(&n->mac, mac, sizeof(*mac));
|
||||||
n->flags |= ZEBRA_NEIGH_ENT_ACTIVE;
|
SET_FLAG(n->flags, ZEBRA_NEIGH_ENT_ACTIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add to rb_tree */
|
/* Add to rb_tree */
|
||||||
@ -118,10 +118,8 @@ static void zebra_neigh_free(struct zebra_neigh_ent *n)
|
|||||||
/* if rules are still using the neigh mark it as inactive and
|
/* if rules are still using the neigh mark it as inactive and
|
||||||
* update the dataplane
|
* update the dataplane
|
||||||
*/
|
*/
|
||||||
if (n->flags & ZEBRA_NEIGH_ENT_ACTIVE) {
|
UNSET_FLAG(n->flags, ZEBRA_NEIGH_ENT_ACTIVE);
|
||||||
n->flags &= ~ZEBRA_NEIGH_ENT_ACTIVE;
|
memset(&n->mac, 0, sizeof(n->mac));
|
||||||
memset(&n->mac, 0, sizeof(n->mac));
|
|
||||||
}
|
|
||||||
zebra_neigh_pbr_rules_update(n);
|
zebra_neigh_pbr_rules_update(n);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -181,7 +179,7 @@ void zebra_neigh_add(struct interface *ifp, struct ipaddr *ip,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
memcpy(&n->mac, mac, sizeof(*mac));
|
memcpy(&n->mac, mac, sizeof(*mac));
|
||||||
n->flags |= ZEBRA_NEIGH_ENT_ACTIVE;
|
SET_FLAG(n->flags, ZEBRA_NEIGH_ENT_ACTIVE);
|
||||||
|
|
||||||
/* update rules linked to the neigh */
|
/* update rules linked to the neigh */
|
||||||
zebra_neigh_pbr_rules_update(n);
|
zebra_neigh_pbr_rules_update(n);
|
||||||
@ -201,7 +199,7 @@ void zebra_neigh_deref(struct zebra_pbr_rule *rule)
|
|||||||
rule->action.neigh = NULL;
|
rule->action.neigh = NULL;
|
||||||
/* remove rule from the list and free if it is inactive */
|
/* remove rule from the list and free if it is inactive */
|
||||||
list_delete_node(n->pbr_rule_list, &rule->action.neigh_listnode);
|
list_delete_node(n->pbr_rule_list, &rule->action.neigh_listnode);
|
||||||
if (!(n->flags & ZEBRA_NEIGH_ENT_ACTIVE))
|
if (!CHECK_FLAG(n->flags, ZEBRA_NEIGH_ENT_ACTIVE))
|
||||||
zebra_neigh_free(n);
|
zebra_neigh_free(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#define NETLINK_SOCKET_BUFFER_SIZE 512
|
#define NETLINK_SOCKET_BUFFER_SIZE 512
|
||||||
#define NETLINK_ALIGNTO 4
|
#define NETLINK_ALIGNTO 4
|
||||||
#define NETLINK_ALIGN(len) \
|
#define NETLINK_ALIGN(len) \
|
||||||
(((len) + NETLINK_ALIGNTO - 1) & ~(NETLINK_ALIGNTO - 1))
|
CHECK_FLAG(((len) + NETLINK_ALIGNTO - 1), ~(NETLINK_ALIGNTO - 1))
|
||||||
#define NETLINK_NLATTR_LEN(_a, _b) (unsigned int)((char *)_a - (char *)_b)
|
#define NETLINK_NLATTR_LEN(_a, _b) (unsigned int)((char *)_a - (char *)_b)
|
||||||
|
|
||||||
#endif /* defined(HAVE_NETLINK) */
|
#endif /* defined(HAVE_NETLINK) */
|
||||||
@ -66,7 +66,7 @@ static struct nlmsghdr *initiate_nlh(char *buf, unsigned int *seq, int type)
|
|||||||
nlh->nlmsg_type = type;
|
nlh->nlmsg_type = type;
|
||||||
nlh->nlmsg_flags = NLM_F_REQUEST;
|
nlh->nlmsg_flags = NLM_F_REQUEST;
|
||||||
if (type == RTM_NEWNSID)
|
if (type == RTM_NEWNSID)
|
||||||
nlh->nlmsg_flags |= NLM_F_ACK;
|
SET_FLAG(nlh->nlmsg_flags, NLM_F_ACK);
|
||||||
nlh->nlmsg_seq = *seq = frr_sequence32_next();
|
nlh->nlmsg_seq = *seq = frr_sequence32_next();
|
||||||
return nlh;
|
return nlh;
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ static void zebra_ns_notify_read(struct event *t)
|
|||||||
char *netnspath;
|
char *netnspath;
|
||||||
struct zebra_netns_info *netnsinfo;
|
struct zebra_netns_info *netnsinfo;
|
||||||
|
|
||||||
if (!(event->mask & (IN_CREATE | IN_DELETE)))
|
if (!CHECK_FLAG(event->mask, (IN_CREATE | IN_DELETE)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (offsetof(struct inotify_event, name) + event->len
|
if (offsetof(struct inotify_event, name) + event->len
|
||||||
@ -350,7 +350,7 @@ static void zebra_ns_notify_read(struct event *t)
|
|||||||
memcpy(event_name, event->name, event->len);
|
memcpy(event_name, event->name, event->len);
|
||||||
event_name[event->len - 1] = 0;
|
event_name[event->len - 1] = 0;
|
||||||
|
|
||||||
if (event->mask & IN_DELETE) {
|
if (CHECK_FLAG(event->mask, IN_DELETE)) {
|
||||||
zebra_ns_delete(event_name);
|
zebra_ns_delete(event_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1795,8 +1795,8 @@ static struct nexthop *nexthop_set_resolved(afi_t afi,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newhop->flags & NEXTHOP_FLAG_ONLINK)
|
if (CHECK_FLAG(newhop->flags, NEXTHOP_FLAG_ONLINK))
|
||||||
resolved_hop->flags |= NEXTHOP_FLAG_ONLINK;
|
SET_FLAG(resolved_hop->flags, NEXTHOP_FLAG_ONLINK);
|
||||||
|
|
||||||
/* Copy labels of the resolved route and the parent resolving to it */
|
/* Copy labels of the resolved route and the parent resolving to it */
|
||||||
if (policy) {
|
if (policy) {
|
||||||
|
Loading…
Reference in New Issue
Block a user