Skip to content

Commit

Permalink
zebra: add ZEBRA_IF_DUMMY flag for dummy interfaces
Browse files Browse the repository at this point in the history
Introduce ZEBRA_IF_DUMMY interface flag to identify Linux dummy interfaces [0].
These interfaces behave similarly to loopback interfaces and can be
specially handled by daemons.

[0]: https://github.com/torvalds/linux/blob/master/drivers/net/dummy.c

Signed-off-by: Gabriel Goller <[email protected]>
  • Loading branch information
kaffarell committed Feb 25, 2025
1 parent 3f290c9 commit 80e9671
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/if.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ struct interface {
#define ZEBRA_INTERFACE_SUB (1 << 1)
#define ZEBRA_INTERFACE_LINKDETECTION (1 << 2)
#define ZEBRA_INTERFACE_VRF_LOOPBACK (1 << 3)
#define ZEBRA_INTERFACE_DUMMY (1 << 4)

/* Interface flags. */
uint64_t flags;
Expand Down
3 changes: 3 additions & 0 deletions zebra/if_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ static void netlink_determine_zebra_iftype(const char *kind,
*zif_type = ZEBRA_IF_BOND;
else if (strcmp(kind, "gre") == 0)
*zif_type = ZEBRA_IF_GRE;
else if (strcmp(kind, "dummy") == 0)
*zif_type = ZEBRA_IF_DUMMY;
}

static void netlink_vrf_change(struct nlmsghdr *h, struct rtattr *tb,
Expand Down Expand Up @@ -576,6 +578,7 @@ static void netlink_interface_update_l2info(struct zebra_dplane_ctx *ctx,
case ZEBRA_IF_MACVLAN:
case ZEBRA_IF_VETH:
case ZEBRA_IF_BOND:
case ZEBRA_IF_DUMMY:
break;
}
}
Expand Down
7 changes: 7 additions & 0 deletions zebra/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,9 @@ void if_add_update(struct interface *ifp)

zebra_interface_add_update(ifp);

if (IS_ZEBRA_IF_DUMMY(ifp))
SET_FLAG(ifp->status, ZEBRA_INTERFACE_DUMMY);

if (!CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) {
SET_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE);

Expand Down Expand Up @@ -1616,6 +1619,7 @@ static void interface_update_l2info(struct zebra_dplane_ctx *ctx,
case ZEBRA_IF_MACVLAN:
case ZEBRA_IF_VETH:
case ZEBRA_IF_BOND:
case ZEBRA_IF_DUMMY:
break;
}
}
Expand Down Expand Up @@ -2369,6 +2373,9 @@ static const char *zebra_ziftype_2str(enum zebra_iftype zif_type)
case ZEBRA_IF_GRE:
return "GRE";

case ZEBRA_IF_DUMMY:
return "dummy";

default:
return "Unknown";
}
Expand Down
6 changes: 5 additions & 1 deletion zebra/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ enum zebra_iftype {
ZEBRA_IF_MACVLAN, /* MAC VLAN interface*/
ZEBRA_IF_VETH, /* VETH interface*/
ZEBRA_IF_BOND, /* Bond */
ZEBRA_IF_GRE, /* GRE interface */
ZEBRA_IF_GRE, /* GRE interface */
ZEBRA_IF_DUMMY, /* Dummy interface */
};

/* Zebra "slave" interface type */
Expand Down Expand Up @@ -246,6 +247,9 @@ DECLARE_HOOK(zebra_if_extra_info, (struct vty * vty, struct interface *ifp),
#define IS_ZEBRA_IF_GRE(ifp) \
(((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_GRE)

#define IS_ZEBRA_IF_DUMMY(ifp) \
(((struct zebra_if *)(ifp->info))->zif_type == ZEBRA_IF_DUMMY)

#define IS_ZEBRA_IF_BRIDGE_SLAVE(ifp) \
(((struct zebra_if *)(ifp->info))->zif_slave_type \
== ZEBRA_IF_SLAVE_BRIDGE)
Expand Down
3 changes: 3 additions & 0 deletions zebra/zebra_nb_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ lib_interface_zebra_state_zif_type_get_elem(struct nb_cb_get_elem_args *args)
case ZEBRA_IF_GRE:
type = "frr-zebra:zif-gre";
break;
case ZEBRA_IF_DUMMY:
type = "frr-zebra:zif-dummy";
break;
}

if (!type)
Expand Down

0 comments on commit 80e9671

Please sign in to comment.