babeld: 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:
sri-mohan1 2023-02-14 15:59:29 +05:30
parent 44fab24d25
commit 03b7208c4c
4 changed files with 17 additions and 15 deletions

View File

@ -66,7 +66,7 @@ static vector babel_enable_if; /* enable interfaces (by cmd). */
int babel_ifp_up(struct interface *ifp) int babel_ifp_up(struct interface *ifp)
{ {
debugf(BABEL_DEBUG_IF, "receive a 'interface up'"); debugf(BABEL_DEBUG_IF, "receive an 'interface up'");
interface_recalculate(ifp); interface_recalculate(ifp);
return 0; return 0;
@ -75,7 +75,7 @@ int babel_ifp_up(struct interface *ifp)
int int
babel_ifp_down(struct interface *ifp) babel_ifp_down(struct interface *ifp)
{ {
debugf(BABEL_DEBUG_IF, "receive a 'interface down'"); debugf(BABEL_DEBUG_IF, "receive an 'interface down'");
if (ifp == NULL) { if (ifp == NULL) {
return 0; return 0;
@ -87,7 +87,7 @@ babel_ifp_down(struct interface *ifp)
int babel_ifp_create (struct interface *ifp) int babel_ifp_create (struct interface *ifp)
{ {
debugf(BABEL_DEBUG_IF, "receive a 'interface add'"); debugf(BABEL_DEBUG_IF, "receive an 'interface add'");
interface_recalculate(ifp); interface_recalculate(ifp);
@ -97,7 +97,7 @@ int babel_ifp_create (struct interface *ifp)
int int
babel_ifp_destroy(struct interface *ifp) babel_ifp_destroy(struct interface *ifp)
{ {
debugf(BABEL_DEBUG_IF, "receive a 'interface delete'"); debugf(BABEL_DEBUG_IF, "receive an 'interface delete'");
if (IS_ENABLE(ifp)) if (IS_ENABLE(ifp))
interface_reset(ifp); interface_reset(ifp);
@ -112,7 +112,7 @@ babel_interface_address_add (ZAPI_CALLBACK_ARGS)
struct connected *ifc; struct connected *ifc;
struct prefix *prefix; struct prefix *prefix;
debugf(BABEL_DEBUG_IF, "receive a 'interface address add'"); debugf(BABEL_DEBUG_IF, "receive an 'interface address add'");
ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD,
zclient->ibuf, vrf_id); zclient->ibuf, vrf_id);
@ -148,7 +148,7 @@ babel_interface_address_delete (ZAPI_CALLBACK_ARGS)
struct connected *ifc; struct connected *ifc;
struct prefix *prefix; struct prefix *prefix;
debugf(BABEL_DEBUG_IF, "receive a 'interface address delete'"); debugf(BABEL_DEBUG_IF, "receive an 'interface address delete'");
ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE, ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE,
zclient->ibuf, vrf_id); zclient->ibuf, vrf_id);

View File

@ -100,7 +100,7 @@ if_up(struct interface *ifp)
{ {
return (if_is_operative(ifp) && return (if_is_operative(ifp) &&
ifp->connected != NULL && ifp->connected != NULL &&
(babel_get_if_nfo(ifp)->flags & BABEL_IF_IS_UP)); CHECK_FLAG(babel_get_if_nfo(ifp)->flags, BABEL_IF_IS_UP));
} }
struct buffered_update { struct buffered_update {

View File

@ -139,7 +139,7 @@ DEFUN (debug_babel,
for(i = 0; debug_type[i].str != NULL; i++) { for(i = 0; debug_type[i].str != NULL; i++) {
if (strncmp (debug_type[i].str, argv[2]->arg, if (strncmp (debug_type[i].str, argv[2]->arg,
debug_type[i].str_min_len) == 0) { debug_type[i].str_min_len) == 0) {
debug |= debug_type[i].type; SET_FLAG(debug, debug_type[i].type);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
} }
@ -169,7 +169,7 @@ DEFUN (no_debug_babel,
for (i = 0; debug_type[i].str; i++) { for (i = 0; debug_type[i].str; i++) {
if (strncmp(debug_type[i].str, argv[3]->arg, if (strncmp(debug_type[i].str, argv[3]->arg,
debug_type[i].str_min_len) == 0) { debug_type[i].str_min_len) == 0) {
debug &= ~debug_type[i].type; UNSET_FLAG(debug, debug_type[i].type);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
} }
@ -195,16 +195,18 @@ debug_babel_config_write (struct vty * vty)
lines++; lines++;
} }
else else
{
for (i = 0; debug_type[i].str != NULL; i++) for (i = 0; debug_type[i].str != NULL; i++)
if {
( if (debug_type[i].type != BABEL_DEBUG_ALL
debug_type[i].type != BABEL_DEBUG_ALL && CHECK_FLAG (debug, debug_type[i].type))
&& CHECK_FLAG (debug, debug_type[i].type)
)
{ {
vty_out (vty, "debug babel %s\n", debug_type[i].str); vty_out (vty, "debug babel %s\n", debug_type[i].str);
lines++; lines++;
} }
}
}
if (lines) if (lines)
{ {
vty_out (vty, "!\n"); vty_out (vty, "!\n");

View File

@ -277,7 +277,7 @@ babel_get_myid(void)
exit(1); exit(1);
} }
/* Clear group and global bits */ /* Clear group and global bits */
myid[0] &= ~3; UNSET_FLAG (myid[0], 3);
} }
/* Make some noise so that others notice us, and send retractions in /* Make some noise so that others notice us, and send retractions in