ldpd: remove a few unnecessary functions

The original ldpd(8) daemon in OpenBSD doesn't allow the user to put
non-existing interfaces in the configuration file. For this reason,
the l2vpn_if_find() and l2vpn_pw_find() functions take an ifindex as
an argument.  In FRR's ldpd we can put non-existing interfaces in the
configuration, and they are activated as soon as they are available. For
this reason, we can't lookup interfaces by their ifindex in this port.
The l2vpn_if_find_name() and l2vpn_pw_find_name() functions were
introduced to address this issue. However, since the "find-by-ifindex"
functions are not being used anymore, we can just remove them and rename
the *_find_name() functions removing the "_name" suffix.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
Renato Westphal 2017-03-25 20:52:42 -03:00
parent dbce358222
commit 52bd4c2321
5 changed files with 16 additions and 45 deletions

View File

@ -133,19 +133,7 @@ l2vpn_if_new(struct l2vpn *l2vpn, struct kif *kif)
}
struct l2vpn_if *
l2vpn_if_find(struct l2vpn *l2vpn, unsigned int ifindex)
{
struct l2vpn_if *lif;
RB_FOREACH(lif, l2vpn_if_head, &l2vpn->if_tree)
if (lif->ifindex == ifindex)
return (lif);
return (NULL);
}
struct l2vpn_if *
l2vpn_if_find_name(struct l2vpn *l2vpn, const char *ifname)
l2vpn_if_find(struct l2vpn *l2vpn, const char *ifname)
{
struct l2vpn_if lif;
strlcpy(lif.ifname, ifname, sizeof(lif.ifname));
@ -201,22 +189,7 @@ l2vpn_pw_new(struct l2vpn *l2vpn, struct kif *kif)
}
struct l2vpn_pw *
l2vpn_pw_find(struct l2vpn *l2vpn, unsigned int ifindex)
{
struct l2vpn_pw *pw;
RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_tree)
if (pw->ifindex == ifindex)
return (pw);
RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_inactive_tree)
if (pw->ifindex == ifindex)
return (pw);
return (NULL);
}
struct l2vpn_pw *
l2vpn_pw_find_name(struct l2vpn *l2vpn, const char *ifname)
l2vpn_pw_find(struct l2vpn *l2vpn, const char *ifname)
{
struct l2vpn_pw *pw;
struct l2vpn_pw s;

View File

@ -213,12 +213,10 @@ void l2vpn_del(struct l2vpn *);
void l2vpn_init(struct l2vpn *);
void l2vpn_exit(struct l2vpn *);
struct l2vpn_if *l2vpn_if_new(struct l2vpn *, struct kif *);
struct l2vpn_if *l2vpn_if_find(struct l2vpn *, unsigned int);
struct l2vpn_if *l2vpn_if_find_name(struct l2vpn *, const char *);
struct l2vpn_if *l2vpn_if_find(struct l2vpn *, const char *);
void l2vpn_if_update(struct l2vpn_if *);
struct l2vpn_pw *l2vpn_pw_new(struct l2vpn *, struct kif *);
struct l2vpn_pw *l2vpn_pw_find(struct l2vpn *, unsigned int);
struct l2vpn_pw *l2vpn_pw_find_name(struct l2vpn *, const char *);
struct l2vpn_pw *l2vpn_pw_find(struct l2vpn *, const char *);
void l2vpn_pw_init(struct l2vpn_pw *);
void l2vpn_pw_exit(struct l2vpn_pw *);
void l2vpn_pw_reset(struct l2vpn_pw *);

View File

@ -498,7 +498,7 @@ ldp_vty_get_node(struct vty *vty, void *parent, int node)
case LDP_PSEUDOWIRE_NODE:
pw = VTY_GET_CONTEXT_SUB(l2vpn_pw);
if (pw)
return (l2vpn_pw_find_name(parent, pw->ifname));
return (l2vpn_pw_find(parent, pw->ifname));
break;
default:
fatalx("ldp_vty_get_node: unexpected node");
@ -531,9 +531,9 @@ ldp_iface_is_configured(struct ldpd_conf *xconf, const char *ifname)
return (1);
RB_FOREACH(l2vpn, l2vpn_head, &xconf->l2vpn_tree) {
if (l2vpn_if_find_name(l2vpn, ifname))
if (l2vpn_if_find(l2vpn, ifname))
return (1);
if (l2vpn_pw_find_name(l2vpn, ifname))
if (l2vpn_pw_find(l2vpn, ifname))
return (1);
}
@ -1543,7 +1543,7 @@ ldp_vty_l2vpn_interface(struct vty *vty, struct vty_arg *args[])
l2vpn = ldp_vty_get_node(vty, NULL, LDP_L2VPN_NODE);
VTY_CHECK_CONTEXT(l2vpn);
lif = l2vpn_if_find_name(l2vpn, ifname);
lif = l2vpn_if_find(l2vpn, ifname);
if (disable) {
if (lif == NULL)
@ -1594,7 +1594,7 @@ ldp_vty_l2vpn_pseudowire(struct vty *vty, struct vty_arg *args[])
l2vpn = ldp_vty_get_node(vty, NULL, LDP_L2VPN_NODE);
VTY_CHECK_CONTEXT(l2vpn);
pw = l2vpn_pw_find_name(l2vpn, ifname);
pw = l2vpn_pw_find(l2vpn, ifname);
if (disable) {
if (pw == NULL)

View File

@ -1633,7 +1633,7 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl)
/* merge intefaces */
RB_FOREACH_SAFE(lif, l2vpn_if_head, &l2vpn->if_tree, ftmp) {
/* find deleted interfaces */
if ((xf = l2vpn_if_find_name(xl, lif->ifname)) == NULL) {
if ((xf = l2vpn_if_find(xl, lif->ifname)) == NULL) {
if (ldpd_process == PROC_MAIN)
QOBJ_UNREG (lif);
RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif);
@ -1642,7 +1642,7 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl)
}
RB_FOREACH_SAFE(xf, l2vpn_if_head, &xl->if_tree, ftmp) {
/* find new interfaces */
if ((lif = l2vpn_if_find_name(l2vpn, xf->ifname)) == NULL) {
if ((lif = l2vpn_if_find(l2vpn, xf->ifname)) == NULL) {
RB_REMOVE(l2vpn_if_head, &xl->if_tree, xf);
RB_INSERT(l2vpn_if_head, &l2vpn->if_tree, xf);
xf->l2vpn = l2vpn;
@ -1659,7 +1659,7 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl)
RB_INIT(&pw_aux_list);
RB_FOREACH_SAFE(pw, l2vpn_pw_head, &l2vpn->pw_tree, ptmp) {
/* find deleted active pseudowires */
if ((xp = l2vpn_pw_find_name(xl, pw->ifname)) == NULL) {
if ((xp = l2vpn_pw_find(xl, pw->ifname)) == NULL) {
switch (ldpd_process) {
case PROC_LDE_ENGINE:
l2vpn_pw_exit(pw);
@ -1678,7 +1678,7 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl)
}
RB_FOREACH_SAFE(xp, l2vpn_pw_head, &xl->pw_tree, ptmp) {
/* find new active pseudowires */
if ((pw = l2vpn_pw_find_name(l2vpn, xp->ifname)) == NULL) {
if ((pw = l2vpn_pw_find(l2vpn, xp->ifname)) == NULL) {
RB_REMOVE(l2vpn_pw_head, &xl->pw_tree, xp);
RB_INSERT(l2vpn_pw_head, &l2vpn->pw_tree, xp);
xp->l2vpn = l2vpn;
@ -1788,7 +1788,7 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl)
/* merge inactive pseudowires */
RB_FOREACH_SAFE(pw, l2vpn_pw_head, &l2vpn->pw_inactive_tree, ptmp) {
/* find deleted inactive pseudowires */
if ((xp = l2vpn_pw_find_name(xl, pw->ifname)) == NULL) {
if ((xp = l2vpn_pw_find(xl, pw->ifname)) == NULL) {
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw);
if (ldpd_process == PROC_MAIN)
QOBJ_UNREG (pw);
@ -1797,7 +1797,7 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl)
}
RB_FOREACH_SAFE(xp, l2vpn_pw_head, &xl->pw_inactive_tree, ptmp) {
/* find new inactive pseudowires */
if ((pw = l2vpn_pw_find_name(l2vpn, xp->ifname)) == NULL) {
if ((pw = l2vpn_pw_find(l2vpn, xp->ifname)) == NULL) {
RB_REMOVE(l2vpn_pw_head, &xl->pw_inactive_tree, xp);
RB_INSERT(l2vpn_pw_head, &l2vpn->pw_inactive_tree, xp);
xp->l2vpn = l2vpn;

View File

@ -303,7 +303,7 @@ ldpe_dispatch_main(struct thread *thread)
}
RB_FOREACH(l2vpn, l2vpn_head, &leconf->l2vpn_tree) {
lif = l2vpn_if_find_name(l2vpn, kif->ifname);
lif = l2vpn_if_find(l2vpn, kif->ifname);
if (lif) {
lif->flags = kif->flags;
memcpy(lif->mac, kif->mac,