diff options
Diffstat (limited to 'ospf6d/ospf6_interface.c')
| -rw-r--r-- | ospf6d/ospf6_interface.c | 240 |
1 files changed, 130 insertions, 110 deletions
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index 6b443127ca..1d17a1c233 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -13,10 +13,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with GNU Zebra; see the file COPYING. If not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <zebra.h> @@ -188,6 +187,7 @@ struct ospf6_interface *ospf6_interface_create(struct interface *ifp) oi->state = OSPF6_INTERFACE_DOWN; oi->flag = 0; oi->mtu_ignore = 0; + oi->c_ifmtu = 0; /* Try to adjust I/O buffer size with IfMtu */ oi->ifmtu = ifp->mtu6; @@ -359,6 +359,7 @@ void ospf6_interface_if_del(struct interface *ifp) void ospf6_interface_state_update(struct interface *ifp) { struct ospf6_interface *oi; + unsigned int iobuflen; oi = (struct ospf6_interface *)ifp->info; if (oi == NULL) @@ -368,12 +369,34 @@ void ospf6_interface_state_update(struct interface *ifp) if (CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE)) return; + /* Adjust the mtu values if the kernel told us something new */ + if (ifp->mtu6 != oi->ifmtu) { + /* If nothing configured, accept it and check for buffer size */ + if (!oi->c_ifmtu) { + oi->ifmtu = ifp->mtu6; + iobuflen = ospf6_iobuf_size(ifp->mtu6); + if (oi->ifmtu > iobuflen) { + if (IS_OSPF6_DEBUG_INTERFACE) + zlog_debug( + "Interface %s: IfMtu is adjusted to I/O buffer size: %d.", + ifp->name, iobuflen); + oi->ifmtu = iobuflen; + } + } else if (oi->c_ifmtu > ifp->mtu6) { + oi->ifmtu = ifp->mtu6; + zlog_warn( + "Configured mtu %u on %s overridden by kernel %u", + oi->c_ifmtu, ifp->name, ifp->mtu6); + } else + oi->ifmtu = oi->c_ifmtu; + } + if (if_is_operative(ifp) && (ospf6_interface_get_linklocal_address(oi->interface) || if_is_loopback(oi->interface))) - thread_add_event(master, interface_up, oi, 0); + thread_add_event(master, interface_up, oi, 0, NULL); else - thread_add_event(master, interface_down, oi, 0); + thread_add_event(master, interface_down, oi, 0, NULL); return; } @@ -650,7 +673,7 @@ static u_char dr_election(struct ospf6_interface *oi) if (on->state < OSPF6_NEIGHBOR_TWOWAY) continue; /* Schedule AdjOK. */ - thread_add_event(master, adj_ok, on, 0); + thread_add_event(master, adj_ok, on, 0, NULL); } } @@ -718,7 +741,7 @@ int interface_up(struct thread *thread) "Scheduling %s for sso retry, trial count: %d", oi->interface->name, oi->sso_try_cnt); thread_add_timer(master, interface_up, oi, - OSPF6_INTERFACE_SSO_RETRY_INT); + OSPF6_INTERFACE_SSO_RETRY_INT, NULL); } return 0; } @@ -729,9 +752,11 @@ int interface_up(struct thread *thread) /* Schedule Hello */ if (!CHECK_FLAG(oi->flag, OSPF6_INTERFACE_PASSIVE) - && !if_is_loopback(oi->interface)) - oi->thread_send_hello = - thread_add_event(master, ospf6_hello_send, oi, 0); + && !if_is_loopback(oi->interface)) { + oi->thread_send_hello = NULL; + thread_add_event(master, ospf6_hello_send, oi, 0, + &oi->thread_send_hello); + } /* decide next interface state */ if ((if_is_pointopoint(oi->interface)) @@ -741,7 +766,8 @@ int interface_up(struct thread *thread) ospf6_interface_state_change(OSPF6_INTERFACE_DROTHER, oi); else { ospf6_interface_state_change(OSPF6_INTERFACE_WAITING, oi); - thread_add_timer(master, wait_timer, oi, oi->dead_interval); + thread_add_timer(master, wait_timer, oi, oi->dead_interval, + NULL); } return 0; @@ -860,58 +886,57 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp) else type = "UNKNOWN"; - vty_out(vty, "%s is %s, type %s%s", ifp->name, - updown[if_is_operative(ifp)], type, VNL); - vty_out(vty, " Interface ID: %d%s", ifp->ifindex, VNL); + vty_out(vty, "%s is %s, type %s\n", ifp->name, + updown[if_is_operative(ifp)], type); + vty_out(vty, " Interface ID: %d\n", ifp->ifindex); if (ifp->info == NULL) { - vty_out(vty, " OSPF not enabled on this interface%s", VNL); + vty_out(vty, " OSPF not enabled on this interface\n"); return 0; } else oi = (struct ospf6_interface *)ifp->info; - vty_out(vty, " Internet Address:%s", VNL); + vty_out(vty, " Internet Address:\n"); for (ALL_LIST_ELEMENTS_RO(ifp->connected, i, c)) { p = c->address; prefix2str(p, strbuf, sizeof(strbuf)); switch (p->family) { case AF_INET: - vty_out(vty, " inet : %s%s", strbuf, VNL); + vty_out(vty, " inet : %s\n", strbuf); break; case AF_INET6: - vty_out(vty, " inet6: %s%s", strbuf, VNL); + vty_out(vty, " inet6: %s\n", strbuf); break; default: - vty_out(vty, " ??? : %s%s", strbuf, VNL); + vty_out(vty, " ??? : %s\n", strbuf); break; } } if (oi->area) { vty_out(vty, - " Instance ID %d, Interface MTU %d (autodetect: %d)%s", - oi->instance_id, oi->ifmtu, ifp->mtu6, VNL); - vty_out(vty, " MTU mismatch detection: %s%s", - oi->mtu_ignore ? "disabled" : "enabled", VNL); + " Instance ID %d, Interface MTU %d (autodetect: %d)\n", + oi->instance_id, oi->ifmtu, ifp->mtu6); + vty_out(vty, " MTU mismatch detection: %s\n", + oi->mtu_ignore ? "disabled" : "enabled"); inet_ntop(AF_INET, &oi->area->area_id, strbuf, sizeof(strbuf)); - vty_out(vty, " Area ID %s, Cost %u%s", strbuf, oi->cost, VNL); + vty_out(vty, " Area ID %s, Cost %u\n", strbuf, oi->cost); } else - vty_out(vty, " Not Attached to Area%s", VNL); + vty_out(vty, " Not Attached to Area\n"); - vty_out(vty, " State %s, Transmit Delay %d sec, Priority %d%s", + vty_out(vty, " State %s, Transmit Delay %d sec, Priority %d\n", ospf6_interface_state_str[oi->state], oi->transdelay, - oi->priority, VNL); - vty_out(vty, " Timer intervals configured:%s", VNL); - vty_out(vty, " Hello %d, Dead %d, Retransmit %d%s", - oi->hello_interval, oi->dead_interval, oi->rxmt_interval, VNL); + oi->priority); + vty_out(vty, " Timer intervals configured:\n"); + vty_out(vty, " Hello %d, Dead %d, Retransmit %d\n", + oi->hello_interval, oi->dead_interval, oi->rxmt_interval); inet_ntop(AF_INET, &oi->drouter, drouter, sizeof(drouter)); inet_ntop(AF_INET, &oi->bdrouter, bdrouter, sizeof(bdrouter)); - vty_out(vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL); + vty_out(vty, " DR: %s BDR: %s\n", drouter, bdrouter); - vty_out(vty, " Number of I/F scoped LSAs is %u%s", oi->lsdb->count, - VNL); + vty_out(vty, " Number of I/F scoped LSAs is %u\n", oi->lsdb->count); monotime(&now); @@ -920,23 +945,21 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp) timersub(&oi->thread_send_lsupdate->u.sands, &now, &res); timerstring(&res, duration, sizeof(duration)); vty_out(vty, - " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s", + " %d Pending LSAs for LSUpdate in Time %s [thread %s]\n", oi->lsupdate_list->count, duration, - (oi->thread_send_lsupdate ? "on" : "off"), VNL); - for (lsa = ospf6_lsdb_head(oi->lsupdate_list); lsa; - lsa = ospf6_lsdb_next(lsa)) - vty_out(vty, " %s%s", lsa->name, VNL); + (oi->thread_send_lsupdate ? "on" : "off")); + for (ALL_LSDB(oi->lsupdate_list, lsa)) + vty_out(vty, " %s\n", lsa->name); timerclear(&res); if (oi->thread_send_lsack) timersub(&oi->thread_send_lsack->u.sands, &now, &res); timerstring(&res, duration, sizeof(duration)); - vty_out(vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s", + vty_out(vty, " %d Pending LSAs for LSAck in Time %s [thread %s]\n", oi->lsack_list->count, duration, - (oi->thread_send_lsack ? "on" : "off"), VNL); - for (lsa = ospf6_lsdb_head(oi->lsack_list); lsa; - lsa = ospf6_lsdb_next(lsa)) - vty_out(vty, " %s%s", lsa->name, VNL); + (oi->thread_send_lsack ? "on" : "off")); + for (ALL_LSDB(oi->lsack_list, lsa)) + vty_out(vty, " %s\n", lsa->name); ospf6_bfd_show_info(vty, oi->bfd_info, 1); return 0; } @@ -958,8 +981,8 @@ DEFUN (show_ipv6_ospf6_interface, if (argc == 5) { ifp = if_lookup_by_name(argv[idx_ifname]->arg, VRF_DEFAULT); if (ifp == NULL) { - vty_out(vty, "No such Interface: %s%s", - argv[idx_ifname]->arg, VNL); + vty_out(vty, "No such Interface: %s\n", + argv[idx_ifname]->arg); return CMD_WARNING; } ospf6_interface_show(vty, ifp); @@ -992,15 +1015,14 @@ DEFUN (show_ipv6_ospf6_interface_ifname_prefix, ifp = if_lookup_by_name(argv[idx_ifname]->arg, VRF_DEFAULT); if (ifp == NULL) { - vty_out(vty, "No such Interface: %s%s", argv[idx_ifname]->arg, - VNL); + vty_out(vty, "No such Interface: %s\n", argv[idx_ifname]->arg); return CMD_WARNING; } oi = ifp->info; if (oi == NULL) { - vty_out(vty, "OSPFv3 is not enabled on %s%s", - argv[idx_ifname]->arg, VNL); + vty_out(vty, "OSPFv3 is not enabled on %s\n", + argv[idx_ifname]->arg); return CMD_WARNING; } @@ -1066,32 +1088,32 @@ DEFUN (ipv6_ospf6_ifmtu, ifmtu = strtol(argv[idx_number]->arg, NULL, 10); - if (oi->ifmtu == ifmtu) + if (oi->c_ifmtu == ifmtu) return CMD_SUCCESS; if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu) { vty_out(vty, - "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s", - ifp->name, ifp->mtu6, VNL); - return CMD_WARNING; + "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)\n", + ifp->name, ifp->mtu6); + return CMD_WARNING_CONFIG_FAILED; } if (oi->ifmtu < ifmtu) { iobuflen = ospf6_iobuf_size(ifmtu); if (iobuflen < ifmtu) { vty_out(vty, - "%s's ifmtu is adjusted to I/O buffer size (%d).%s", - ifp->name, iobuflen, VNL); - oi->ifmtu = iobuflen; + "%s's ifmtu is adjusted to I/O buffer size (%d).\n", + ifp->name, iobuflen); + oi->ifmtu = oi->c_ifmtu = iobuflen; } else - oi->ifmtu = ifmtu; + oi->ifmtu = oi->c_ifmtu = ifmtu; } else - oi->ifmtu = ifmtu; + oi->ifmtu = oi->c_ifmtu = ifmtu; /* re-establish adjacencies */ for (ALL_LIST_ELEMENTS(oi->neighbor_list, node, nnode, on)) { THREAD_OFF(on->inactivity_timer); - thread_add_event(master, inactivity_timer, on, 0); + thread_add_event(master, inactivity_timer, on, 0, NULL); } return CMD_SUCCESS; @@ -1099,11 +1121,12 @@ DEFUN (ipv6_ospf6_ifmtu, DEFUN (no_ipv6_ospf6_ifmtu, no_ipv6_ospf6_ifmtu_cmd, - "no ipv6 ospf6 ifmtu", + "no ipv6 ospf6 ifmtu [(1-65535)]", NO_STR IP6_STR OSPF6_STR "Interface MTU\n" + "OSPFv3 Interface MTU\n" ) { VTY_DECLVAR_CONTEXT(interface, ifp); @@ -1123,18 +1146,20 @@ DEFUN (no_ipv6_ospf6_ifmtu, iobuflen = ospf6_iobuf_size(ifp->mtu); if (iobuflen < ifp->mtu) { vty_out(vty, - "%s's ifmtu is adjusted to I/O buffer size (%d).%s", - ifp->name, iobuflen, VNL); + "%s's ifmtu is adjusted to I/O buffer size (%d).\n", + ifp->name, iobuflen); oi->ifmtu = iobuflen; } else oi->ifmtu = ifp->mtu; } else oi->ifmtu = ifp->mtu; + oi->c_ifmtu = 0; + /* re-establish adjacencies */ for (ALL_LIST_ELEMENTS(oi->neighbor_list, node, nnode, on)) { THREAD_OFF(on->inactivity_timer); - thread_add_event(master, inactivity_timer, on, 0); + thread_add_event(master, inactivity_timer, on, 0, NULL); } return CMD_SUCCESS; @@ -1164,8 +1189,8 @@ DEFUN (ipv6_ospf6_cost, lcost = strtol(argv[idx_number]->arg, NULL, 10); if (lcost > UINT32_MAX) { - vty_out(vty, "Cost %ld is out of range%s", lcost, VNL); - return CMD_WARNING; + vty_out(vty, "Cost %ld is out of range\n", lcost); + return CMD_WARNING_CONFIG_FAILED; } if (oi->cost == lcost) @@ -1220,9 +1245,8 @@ DEFUN (auto_cost_reference_bandwidth, refbw = strtol(argv[idx_number]->arg, NULL, 10); if (refbw < 1 || refbw > 4294967) { - vty_out(vty, "reference-bandwidth value is invalid%s", - VTY_NEWLINE); - return CMD_WARNING; + vty_out(vty, "reference-bandwidth value is invalid\n"); + return CMD_WARNING_CONFIG_FAILED; } /* If reference bandwidth is changed. */ @@ -1434,7 +1458,7 @@ DEFUN (ipv6_ospf6_passive, for (ALL_LIST_ELEMENTS(oi->neighbor_list, node, nnode, on)) { THREAD_OFF(on->inactivity_timer); - thread_add_event(master, inactivity_timer, on, 0); + thread_add_event(master, inactivity_timer, on, 0, NULL); } return CMD_SUCCESS; @@ -1460,8 +1484,9 @@ DEFUN (no_ipv6_ospf6_passive, UNSET_FLAG(oi->flag, OSPF6_INTERFACE_PASSIVE); THREAD_OFF(oi->thread_send_hello); - oi->thread_send_hello = - thread_add_event(master, ospf6_hello_send, oi, 0); + oi->thread_send_hello = NULL; + thread_add_event(master, ospf6_hello_send, oi, 0, + &oi->thread_send_hello); return CMD_SUCCESS; } @@ -1621,8 +1646,8 @@ DEFUN (ipv6_ospf6_network, } /* Reset the interface */ - thread_add_event(master, interface_down, oi, 0); - thread_add_event(master, interface_up, oi, 0); + thread_add_event(master, interface_down, oi, 0, NULL); + thread_add_event(master, interface_up, oi, 0, NULL); return CMD_SUCCESS; } @@ -1633,9 +1658,7 @@ DEFUN (no_ipv6_ospf6_network, NO_STR IP6_STR OSPF6_STR - "Network type\n" - "Default to whatever interface type system specifies" - ) + "Set default network type\n") { VTY_DECLVAR_CONTEXT(interface, ifp); struct ospf6_interface *oi; @@ -1655,8 +1678,8 @@ DEFUN (no_ipv6_ospf6_network, oi->type = type; /* Reset the interface */ - thread_add_event(master, interface_down, oi, 0); - thread_add_event(master, interface_up, oi, 0); + thread_add_event(master, interface_down, oi, 0, NULL); + thread_add_event(master, interface_up, oi, 0, NULL); return CMD_SUCCESS; } @@ -1672,63 +1695,60 @@ static int config_write_ospf6_interface(struct vty *vty) if (oi == NULL) continue; - vty_out(vty, "interface %s%s", oi->interface->name, VNL); + vty_out(vty, "interface %s\n", oi->interface->name); if (ifp->desc) - vty_out(vty, " description %s%s", ifp->desc, VNL); - if (ifp->mtu6 != oi->ifmtu) - vty_out(vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL); + vty_out(vty, " description %s\n", ifp->desc); + if (oi->c_ifmtu) + vty_out(vty, " ipv6 ospf6 ifmtu %d\n", oi->c_ifmtu); if (CHECK_FLAG(oi->flag, OSPF6_INTERFACE_NOAUTOCOST)) - vty_out(vty, " ipv6 ospf6 cost %d%s", oi->cost, VNL); + vty_out(vty, " ipv6 ospf6 cost %d\n", oi->cost); if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL) - vty_out(vty, " ipv6 ospf6 hello-interval %d%s", - oi->hello_interval, VNL); + vty_out(vty, " ipv6 ospf6 hello-interval %d\n", + oi->hello_interval); if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL) - vty_out(vty, " ipv6 ospf6 dead-interval %d%s", - oi->dead_interval, VNL); + vty_out(vty, " ipv6 ospf6 dead-interval %d\n", + oi->dead_interval); if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL) - vty_out(vty, " ipv6 ospf6 retransmit-interval %d%s", - oi->rxmt_interval, VNL); + vty_out(vty, " ipv6 ospf6 retransmit-interval %d\n", + oi->rxmt_interval); if (oi->priority != OSPF6_INTERFACE_PRIORITY) - vty_out(vty, " ipv6 ospf6 priority %d%s", oi->priority, - VNL); + vty_out(vty, " ipv6 ospf6 priority %d\n", oi->priority); if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY) - vty_out(vty, " ipv6 ospf6 transmit-delay %d%s", - oi->transdelay, VNL); + vty_out(vty, " ipv6 ospf6 transmit-delay %d\n", + oi->transdelay); if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID) - vty_out(vty, " ipv6 ospf6 instance-id %d%s", - oi->instance_id, VNL); + vty_out(vty, " ipv6 ospf6 instance-id %d\n", + oi->instance_id); if (oi->plist_name) - vty_out(vty, " ipv6 ospf6 advertise prefix-list %s%s", - oi->plist_name, VNL); + vty_out(vty, " ipv6 ospf6 advertise prefix-list %s\n", + oi->plist_name); if (CHECK_FLAG(oi->flag, OSPF6_INTERFACE_PASSIVE)) - vty_out(vty, " ipv6 ospf6 passive%s", VNL); + vty_out(vty, " ipv6 ospf6 passive\n"); if (oi->mtu_ignore) - vty_out(vty, " ipv6 ospf6 mtu-ignore%s", VNL); + 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%s", - VNL); + " ipv6 ospf6 network point-to-point\n"); else if (oi->type == OSPF_IFTYPE_BROADCAST) - vty_out(vty, " ipv6 ospf6 network broadcast%s", - VNL); + vty_out(vty, " ipv6 ospf6 network broadcast\n"); } ospf6_bfd_write_config(vty, oi); - vty_out(vty, "!%s", VNL); + vty_out(vty, "!\n"); } return 0; } @@ -1794,8 +1814,8 @@ static void ospf6_interface_clear(struct vty *vty, struct interface *ifp) zlog_debug("Interface %s: clear by reset", ifp->name); /* Reset the interface */ - thread_add_event(master, interface_down, oi, 0); - thread_add_event(master, interface_up, oi, 0); + thread_add_event(master, interface_down, oi, 0, NULL); + thread_add_event(master, interface_up, oi, 0, NULL); } /* Clear interface */ @@ -1822,8 +1842,8 @@ DEFUN (clear_ipv6_ospf6_interface, if ((ifp = if_lookup_by_name(argv[idx_ifname]->arg, VRF_DEFAULT)) == NULL) { - vty_out(vty, "No such Interface: %s%s", - argv[idx_ifname]->arg, VNL); + vty_out(vty, "No such Interface: %s\n", + argv[idx_ifname]->arg); return CMD_WARNING; } ospf6_interface_clear(vty, ifp); @@ -1865,7 +1885,7 @@ DEFUN (no_debug_ospf6_interface, int config_write_ospf6_debug_interface(struct vty *vty) { if (IS_OSPF6_DEBUG_INTERFACE) - vty_out(vty, "debug ospf6 interface%s", VNL); + vty_out(vty, "debug ospf6 interface\n"); return 0; } |
