Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ospf6d: fix interface type handling #4995

Merged
merged 3 commits into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
ospf6d: track explicit interface type config
If the interface doesn't exist in system, we'll default to broadcast and
then later not change that when the interface comes up.  Explicitly
track whether the user configured the type and properly auto-set it if
they didn't.

Fixes: #3930
Fixes: #4873
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
  • Loading branch information
eqvinox committed Sep 17, 2019
commit 5aeb4f3c60789b09b5194da5ea63d036d6c80f6c
50 changes: 32 additions & 18 deletions ospf6d/ospf6_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,9 @@ int interface_up(struct thread *thread)
oi = (struct ospf6_interface *)THREAD_ARG(thread);
assert(oi && oi->interface);

if (!oi->type_cfg)
oi->type = ospf6_default_iftype(oi->interface);

/*
* Remove old pointer. If this thread wasn't a timer this
* operation won't make a difference, because it is already NULL.
Expand Down Expand Up @@ -877,6 +880,19 @@ int interface_down(struct thread *thread)
}


static const char *ospf6_iftype_str(uint8_t iftype)
{
switch (iftype) {
case OSPF_IFTYPE_LOOPBACK:
return "LOOPBACK";
case OSPF_IFTYPE_BROADCAST:
return "BROADCAST";
case OSPF_IFTYPE_POINTOPOINT:
return "POINTOPOINT";
}
return "UNKNOWN";
}

/* show specified interface structure */
static int ospf6_interface_show(struct vty *vty, struct interface *ifp)
{
Expand All @@ -885,23 +901,16 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp)
struct prefix *p;
struct listnode *i;
char strbuf[PREFIX2STR_BUFFER], drouter[32], bdrouter[32];
const char *type;
uint8_t default_iftype;
struct timeval res, now;
char duration[32];
struct ospf6_lsa *lsa;

/* check physical interface type */
if (if_is_loopback(ifp))
type = "LOOPBACK";
else if (if_is_broadcast(ifp))
type = "BROADCAST";
else if (if_is_pointopoint(ifp))
type = "POINTOPOINT";
else
type = "UNKNOWN";
default_iftype = ospf6_default_iftype(ifp);

vty_out(vty, "%s is %s, type %s\n", ifp->name,
(if_is_operative(ifp) ? "up" : "down"), type);
(if_is_operative(ifp) ? "up" : "down"),
ospf6_iftype_str(default_iftype));
vty_out(vty, " Interface ID: %d\n", ifp->ifindex);

if (ifp->info == NULL) {
Expand All @@ -910,6 +919,10 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp)
} else
oi = (struct ospf6_interface *)ifp->info;

if (if_is_operative(ifp) && oi->type != default_iftype)
vty_out(vty, " Operating as type %s\n",
ospf6_iftype_str(oi->type));

vty_out(vty, " Internet Address:\n");

for (ALL_LIST_ELEMENTS_RO(ifp->connected, i, c)) {
Expand Down Expand Up @@ -1806,6 +1819,8 @@ DEFUN (ipv6_ospf6_network,
}
assert(oi);

oi->type_cfg = true;

if (strncmp(argv[idx_network]->arg, "b", 1) == 0) {
if (oi->type == OSPF_IFTYPE_BROADCAST)
return CMD_SUCCESS;
Expand Down Expand Up @@ -1846,6 +1861,8 @@ DEFUN (no_ipv6_ospf6_network,
return CMD_SUCCESS;
}

oi->type_cfg = false;

type = ospf6_default_iftype(ifp);
if (oi->type == type) {
return CMD_SUCCESS;
Expand Down Expand Up @@ -1913,13 +1930,10 @@ static int config_write_ospf6_interface(struct vty *vty)
if (oi->mtu_ignore)
vty_out(vty, " ipv6 ospf6 mtu-ignore\n");

if (oi->type != ospf6_default_iftype(ifp)) {
if (oi->type == OSPF_IFTYPE_POINTOPOINT)
vty_out(vty,
" ipv6 ospf6 network point-to-point\n");
else if (oi->type == OSPF_IFTYPE_BROADCAST)
vty_out(vty, " ipv6 ospf6 network broadcast\n");
}
if (oi->type_cfg && oi->type == OSPF_IFTYPE_POINTOPOINT)
vty_out(vty, " ipv6 ospf6 network point-to-point\n");
else if (oi->type_cfg && oi->type == OSPF_IFTYPE_BROADCAST)
vty_out(vty, " ipv6 ospf6 network broadcast\n");

ospf6_bfd_write_config(vty, oi);

Expand Down
1 change: 1 addition & 0 deletions ospf6d/ospf6_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ struct ospf6_interface {

/* Network Type */
uint8_t type;
bool type_cfg;

/* Router Priority */
uint8_t priority;
Expand Down