From bc97889b393288cc950f4cc8fd5f175c45b398ed Mon Sep 17 00:00:00 2001 From: Amol Lad Date: Wed, 17 Feb 2021 13:51:52 +1300 Subject: [PATCH] ospfd: Support use of ospf with DMVPN Signed-off-by: Reuben Dowle --- ospfd/ospf_interface.c | 2 ++ ospfd/ospf_interface.h | 6 ++++++ ospfd/ospf_lsa.c | 12 ++++++++++-- ospfd/ospf_vty.c | 37 +++++++++++++++++++++++++------------ ospfd/ospfd.c | 1 + 5 files changed, 44 insertions(+), 14 deletions(-) diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 6829c4a347..9bb28baa72 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -543,6 +543,8 @@ static struct ospf_if_params *ospf_new_if_params(void) oip->network_lsa_seqnum = htonl(OSPF_INITIAL_SEQUENCE_NUMBER); oip->is_v_wait_set = false; + oip->ptp_dmvpn = 0; + return oip; } diff --git a/ospfd/ospf_interface.h b/ospfd/ospf_interface.h index e2d7327381..4a21147246 100644 --- a/ospfd/ospf_interface.h +++ b/ospfd/ospf_interface.h @@ -118,6 +118,9 @@ struct ospf_if_params { /* MPLS LDP-IGP Sync configuration */ struct ldp_sync_info *ldp_sync_info; + + /* point-to-point DMVPN configuration */ + uint8_t ptp_dmvpn; }; enum { MEMBER_ALLROUTERS = 0, @@ -180,6 +183,9 @@ struct ospf_interface { /* OSPF Network Type. */ uint8_t type; + /* point-to-point DMVPN configuration */ + uint8_t ptp_dmvpn; + /* State of Interface State Machine. */ uint8_t state; diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index cb1c565d37..6e9df77fb8 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -469,6 +469,12 @@ char link_info_set(struct stream **s, struct in_addr id, struct in_addr data, } /* Describe Point-to-Point link (Section 12.4.1.1). */ + +/* Note: If the interface is configured as point-to-point dmvpn then the other + * end of link is dmvpn hub with point-to-multipoint ospf network type. The + * hub then expects this router to populate the stub network and also Link Data + * Field set to IP Address and not MIB-II ifIndex + */ static int lsa_link_ptop_set(struct stream **s, struct ospf_interface *oi) { int links = 0; @@ -482,7 +488,8 @@ static int lsa_link_ptop_set(struct stream **s, struct ospf_interface *oi) if ((nbr = ospf_nbr_lookup_ptop(oi))) if (nbr->state == NSM_Full) { if (CHECK_FLAG(oi->connected->flags, - ZEBRA_IFA_UNNUMBERED)) { + ZEBRA_IFA_UNNUMBERED) + && !oi->ptp_dmvpn) { /* For unnumbered point-to-point networks, the Link Data field should specify the interface's MIB-II ifIndex @@ -500,7 +507,8 @@ static int lsa_link_ptop_set(struct stream **s, struct ospf_interface *oi) } /* no need for a stub link for unnumbered interfaces */ - if (!CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED)) { + if (oi->ptp_dmvpn + || !CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED)) { /* Regardless of the state of the neighboring router, we must add a Type 3 link (stub network). N.B. Options 1 & 2 share basically the same logic. */ diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index a1dac641d7..2803354a03 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -8392,6 +8392,7 @@ DEFUN (no_ip_ospf_hello_interval, continue; oi->type = IF_DEF_PARAMS(ifp)->type; + oi->ptp_dmvpn = IF_DEF_PARAMS(ifp)->ptp_dmvpn; if (oi->state > ISM_Down) { OSPF_ISM_EVENT_EXECUTE(oi, ISM_InterfaceDown); @@ -8419,20 +8420,21 @@ DEFUN_HIDDEN (no_ospf_hello_interval, return no_ip_ospf_hello_interval(self, vty, argc, argv); } -DEFUN (ip_ospf_network, - ip_ospf_network_cmd, - "ip ospf network ", - "IP Information\n" - "OSPF interface commands\n" - "Network type\n" - "Specify OSPF broadcast multi-access network\n" - "Specify OSPF NBMA network\n" - "Specify OSPF point-to-multipoint network\n" - "Specify OSPF point-to-point network\n") +DEFUN(ip_ospf_network, ip_ospf_network_cmd, + "ip ospf network ", + "IP Information\n" + "OSPF interface commands\n" + "Network type\n" + "Specify OSPF broadcast multi-access network\n" + "Specify OSPF NBMA network\n" + "Specify OSPF point-to-multipoint network\n" + "Specify OSPF point-to-point network\n" + "Specify OSPF point-to-point DMVPN network\n") { VTY_DECLVAR_CONTEXT(interface, ifp); int idx = 0; int old_type = IF_DEF_PARAMS(ifp)->type; + uint8_t old_ptp_dmvpn = IF_DEF_PARAMS(ifp)->ptp_dmvpn; struct route_node *rn; if (old_type == OSPF_IFTYPE_LOOPBACK) { @@ -8441,16 +8443,22 @@ DEFUN (ip_ospf_network, return CMD_WARNING_CONFIG_FAILED; } + IF_DEF_PARAMS(ifp)->ptp_dmvpn = 0; + if (argv_find(argv, argc, "broadcast", &idx)) IF_DEF_PARAMS(ifp)->type = OSPF_IFTYPE_BROADCAST; else if (argv_find(argv, argc, "non-broadcast", &idx)) IF_DEF_PARAMS(ifp)->type = OSPF_IFTYPE_NBMA; else if (argv_find(argv, argc, "point-to-multipoint", &idx)) IF_DEF_PARAMS(ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; - else if (argv_find(argv, argc, "point-to-point", &idx)) + else if (argv_find(argv, argc, "point-to-point", &idx)) { IF_DEF_PARAMS(ifp)->type = OSPF_IFTYPE_POINTOPOINT; + if (argv_find(argv, argc, "dmvpn", &idx)) + IF_DEF_PARAMS(ifp)->ptp_dmvpn = 1; + } - if (IF_DEF_PARAMS(ifp)->type == old_type) + if (IF_DEF_PARAMS(ifp)->type == old_type + && IF_DEF_PARAMS(ifp)->ptp_dmvpn == old_ptp_dmvpn) return CMD_SUCCESS; SET_IF_PARAM(IF_DEF_PARAMS(ifp), type); @@ -8502,6 +8510,7 @@ DEFUN (no_ip_ospf_network, struct route_node *rn; IF_DEF_PARAMS(ifp)->type = ospf_default_iftype(ifp); + IF_DEF_PARAMS(ifp)->ptp_dmvpn = 0; if (IF_DEF_PARAMS(ifp)->type == old_type) return CMD_SUCCESS; @@ -11644,6 +11653,10 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf) vty_out(vty, " ip ospf network %s", ospf_int_type_str [params->type]); + if (params->type + == OSPF_IFTYPE_POINTOPOINT + && params->ptp_dmvpn) + vty_out(vty, " dmvpn"); if (params != IF_DEF_PARAMS(ifp) && rn) vty_out(vty, " %pI4", &rn->p.u.prefix4); diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index 259209a736..9949a78336 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -1076,6 +1076,7 @@ struct ospf_interface *add_ospf_interface(struct connected *co, /* If network type is specified previously, skip network type setting. */ oi->type = IF_DEF_PARAMS(co->ifp)->type; + oi->ptp_dmvpn = IF_DEF_PARAMS(co->ifp)->ptp_dmvpn; /* Add pseudo neighbor. */ ospf_nbr_self_reset(oi, oi->ospf->router_id); -- 2.39.5