]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #2868 from opensourcerouting/snap-rpki
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 21 Aug 2018 22:49:24 +0000 (18:49 -0400)
committerGitHub <noreply@github.com>
Tue, 21 Aug 2018 22:49:24 +0000 (18:49 -0400)
snapcraft: Add RPKI to snap package

27 files changed:
bgpd/bgp_flowspec_vty.c
bgpd/bgp_pbr.c
bgpd/bgp_route.c
bgpd/bgp_vty.c
debianpkg/backports/ubuntu12.04/debian/rules
debianpkg/backports/ubuntu14.04/debian/rules
debianpkg/rules
doc/manpages/common-options.rst
doc/manpages/index.rst
doc/user/bfd.rst
lib/ferr.c
lib/log.c
ospf6d/ospf6_flood.c
ospfclient/ospf_apiclient.c
ospfd/ospf_apiserver.c
ospfd/ospf_asbr.c
ospfd/ospf_asbr.h
ospfd/ospf_ext.c
ospfd/ospf_flood.c
ospfd/ospf_lsa.c
ospfd/ospf_lsa.h
ospfd/ospf_main.c
ospfd/ospf_packet.c
ospfd/ospf_ri.c
ospfd/ospf_snmp.c
ospfd/ospf_te.c
ospfd/ospfd.c

index f8c06132084eb8b465387d0de98da3aabeff3f26..31d2c540fa524e2d044a299daad914ea6457cfef 100644 (file)
@@ -335,7 +335,7 @@ void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
                        struct listnode *node;
                        struct bgp_pbr_match_entry *bpme;
                        struct bgp_pbr_match *bpm;
-                       int unit = 0;
+                       bool list_began = false;
                        struct list *list_bpm;
 
                        list_bpm = list_new();
@@ -347,14 +347,14 @@ void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
                                if (listnode_lookup(list_bpm, bpm))
                                        continue;
                                listnode_add(list_bpm, bpm);
-                               if (unit == 0)
+                               if (!list_began) {
                                        vty_out(vty, " (");
-                               else
+                                       list_began = true;
+                               } else
                                        vty_out(vty, ", ");
                                vty_out(vty, "%s", bpm->ipset_name);
-                               unit++;
                        }
-                       if (unit)
+                       if (list_began)
                                vty_out(vty, ")");
                        vty_out(vty, "\n");
                        list_delete_and_null(&list_bpm);
index 129c143a64bce6b54eca4e51883bd1a2c851a831..b182fde1e2ec5d0d495be6f7dd152ab993b26623 100644 (file)
@@ -1680,7 +1680,7 @@ static void bgp_pbr_dump_entry(struct bgp_pbr_filter *bpf, bool add)
                         ? "!" : "",
                         bpf->dscp->val);
        }
-       zlog_info("BGP: %s FS PBR from %s to %s, %s %s",
+       zlog_debug("BGP: %s FS PBR from %s to %s, %s %s",
                  add ? "adding" : "removing",
                  bpf->src == NULL ? "<all>" :
                  prefix2str(bpf->src, bufsrc, sizeof(bufsrc)),
@@ -1807,7 +1807,7 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
                       bgp_pbr_match_alloc_intern);
 
        /* new, then self allocate ipset_name and unique */
-       if (bpm && bpm->unique == 0) {
+       if (bpm->unique == 0) {
                bpm->unique = ++bgp_pbr_match_counter_unique;
                /* 0 value is forbidden */
                sprintf(bpm->ipset_name, "match%p", bpm);
@@ -1838,10 +1838,9 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
        temp2.src_port_max = src_port ? src_port->max_port : 0;
        temp2.dst_port_max = dst_port ? dst_port->max_port : 0;
        temp2.proto = bpf->protocol;
-       if (bpm)
-               bpme = hash_get(bpm->entry_hash, &temp2,
-                               bgp_pbr_match_entry_alloc_intern);
-       if (bpme && bpme->unique == 0) {
+       bpme = hash_get(bpm->entry_hash, &temp2,
+                       bgp_pbr_match_entry_alloc_intern);
+       if (bpme->unique == 0) {
                bpme->unique = ++bgp_pbr_match_entry_counter_unique;
                /* 0 value is forbidden */
                bpme->backpointer = bpm;
@@ -1853,7 +1852,7 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
                bpme_found = true;
 
        /* already installed */
-       if (bpme_found && bpme) {
+       if (bpme_found) {
                struct bgp_info_extra *extra = bgp_info_extra_get(binfo);
 
                if (extra && extra->bgp_fs_pbr &&
index 041049d05b3f52550db0e72e6cf124030e81d3ce..eedfe7503e5437bdd41d6c71c3c54203f6faf4fc 100644 (file)
@@ -198,8 +198,7 @@ static void bgp_info_extra_free(struct bgp_info_extra **extra)
                bgp_unlock(e->bgp_orig);
 
        if ((*extra)->bgp_fs_pbr)
-               list_delete_all_node((*extra)->bgp_fs_pbr);
-       (*extra)->bgp_fs_pbr = NULL;
+               list_delete_and_null(&((*extra)->bgp_fs_pbr));
        XFREE(MTYPE_BGP_ROUTE_EXTRA, *extra);
 
        *extra = NULL;
index fda458cb84f41cebf93aeaa712befd4cb28c1c51..98d9ffccebff27ce4256826e06cb87df7414173c 100644 (file)
@@ -10995,7 +10995,7 @@ DEFUN (show_ip_bgp_attr_info,
 }
 
 static int bgp_show_route_leak_vty(struct vty *vty, const char *name,
-                                  afi_t afi, safi_t safi)
+                                  afi_t afi, safi_t safi, uint8_t use_json)
 {
        struct bgp *bgp;
        struct listnode *node;
@@ -11004,64 +11004,148 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name,
        char *ecom_str;
        vpn_policy_direction_t dir;
 
-       if (name) {
-               bgp = bgp_lookup_by_name(name);
+       if (use_json) {
+               json_object *json = NULL;
+               json_object *json_import_vrfs = NULL;
+               json_object *json_export_vrfs = NULL;
+
+               json = json_object_new_object();
+
+               /* Provide context for the block */
+               json_object_string_add(json, "vrf", name ? name : "default");
+               json_object_string_add(json, "afiSafi",
+                                       afi_safi_print(afi, safi));
+
+               bgp = name ? bgp_lookup_by_name(name) : bgp_get_default();
+
                if (!bgp) {
-                       vty_out(vty, "%% No such BGP instance exist\n");
+                       json_object_boolean_true_add(json,
+                                                    "bgpNoSuchInstance");
+                       vty_out(vty, "%s\n",
+                               json_object_to_json_string_ext(
+                                       json,
+                                       JSON_C_TO_STRING_PRETTY));
+                       json_object_free(json);
+
                        return CMD_WARNING;
                }
+
+               if (!CHECK_FLAG(bgp->af_flags[afi][safi],
+                               BGP_CONFIG_VRF_TO_VRF_IMPORT)) {
+                       json_object_string_add(json, "importFromVrfs", "none");
+                       json_object_string_add(json, "importRts", "none");
+               } else {
+                       json_import_vrfs = json_object_new_array();
+
+                       for (ALL_LIST_ELEMENTS_RO(
+                                               bgp->vpn_policy[afi].import_vrf,
+                                               node, vname))
+                               json_object_array_add(json_import_vrfs,
+                                               json_object_new_string(vname));
+
+                       dir = BGP_VPN_POLICY_DIR_FROMVPN;
+                       ecom_str = ecommunity_ecom2str(
+                                       bgp->vpn_policy[afi].rtlist[dir],
+                                       ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
+                       json_object_object_add(json, "importFromVrfs",
+                                              json_import_vrfs);
+                       json_object_string_add(json, "importRts", ecom_str);
+
+                       XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+               }
+
+               if (!CHECK_FLAG(bgp->af_flags[afi][safi],
+                               BGP_CONFIG_VRF_TO_VRF_EXPORT)) {
+                       json_object_string_add(json, "exportToVrfs", "none");
+                       json_object_string_add(json, "routeDistinguisher",
+                                              "none");
+                       json_object_string_add(json, "exportRts", "none");
+               } else {
+                       json_export_vrfs = json_object_new_array();
+
+                       for (ALL_LIST_ELEMENTS_RO(
+                                               bgp->vpn_policy[afi].export_vrf,
+                                               node, vname))
+                               json_object_array_add(json_export_vrfs,
+                                               json_object_new_string(vname));
+                       json_object_object_add(json, "exportToVrfs",
+                                              json_export_vrfs);
+                       json_object_string_add(json, "routeDistinguisher",
+                                  prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd,
+                                                buf1, RD_ADDRSTRLEN));
+
+                       dir = BGP_VPN_POLICY_DIR_TOVPN;
+                       ecom_str = ecommunity_ecom2str(
+                                              bgp->vpn_policy[afi].rtlist[dir],
+                                              ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
+                       json_object_string_add(json, "exportRts", ecom_str);
+
+                       XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
+               }
+
+               vty_out(vty, "%s\n",
+                       json_object_to_json_string_ext(json,
+                                                     JSON_C_TO_STRING_PRETTY));
+               json_object_free(json);
+
        } else {
-               bgp = bgp_get_default();
+               bgp = name ? bgp_lookup_by_name(name) : bgp_get_default();
+
                if (!bgp) {
-                       vty_out(vty,
-                               "%% Default BGP instance does not exist\n");
+                       vty_out(vty, "%% No such BGP instance exist\n");
                        return CMD_WARNING;
                }
-       }
 
-       if (!CHECK_FLAG(bgp->af_flags[afi][safi],
-                       BGP_CONFIG_VRF_TO_VRF_IMPORT)) {
-               vty_out(vty,
-                       "This VRF is not importing %s routes from any other VRF\n",
-                       afi_safi_print(afi, safi));
-       } else {
-               vty_out(vty,
-                       "This VRF is importing %s routes from the following VRFs:\n",
-                       afi_safi_print(afi, safi));
-               for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node,
-                                         vname)) {
-                       vty_out(vty, "  %s\n", vname);
+               if (!CHECK_FLAG(bgp->af_flags[afi][safi],
+                               BGP_CONFIG_VRF_TO_VRF_IMPORT))
+                       vty_out(vty,
+                    "This VRF is not importing %s routes from any other VRF\n",
+                     afi_safi_print(afi, safi));
+               else {
+                       vty_out(vty,
+                  "This VRF is importing %s routes from the following VRFs:\n",
+                   afi_safi_print(afi, safi));
+
+                       for (ALL_LIST_ELEMENTS_RO(
+                                               bgp->vpn_policy[afi].import_vrf,
+                                               node, vname))
+                               vty_out(vty, "  %s\n", vname);
+
+                       dir = BGP_VPN_POLICY_DIR_FROMVPN;
+                       ecom_str = ecommunity_ecom2str(
+                                              bgp->vpn_policy[afi].rtlist[dir],
+                                              ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
+                       vty_out(vty, "Import RT(s): %s\n", ecom_str);
+
+                       XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
                }
-               dir = BGP_VPN_POLICY_DIR_FROMVPN;
-               ecom_str = ecommunity_ecom2str(
-                               bgp->vpn_policy[afi].rtlist[dir],
-                               ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
-               vty_out(vty, "Import RT(s): %s\n", ecom_str);
-               XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
-       }
 
-       if (!CHECK_FLAG(bgp->af_flags[afi][safi],
-                       BGP_CONFIG_VRF_TO_VRF_EXPORT)) {
-               vty_out(vty,
-                       "This VRF is not exporting %s routes to any other VRF\n",
+               if (!CHECK_FLAG(bgp->af_flags[afi][safi],
+                               BGP_CONFIG_VRF_TO_VRF_EXPORT))
+                       vty_out(vty,
+                      "This VRF is not exporting %s routes to any other VRF\n",
                        afi_safi_print(afi, safi));
-       } else {
-               vty_out(vty,
-                       "This VRF is exporting %s routes to the following VRFs:\n",
+               else {
+                       vty_out(vty,
+                      "This VRF is exporting %s routes to the following VRFs:\n",
                        afi_safi_print(afi, safi));
-               for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].export_vrf, node,
-                                         vname)) {
-                       vty_out(vty, "  %s\n", vname);
+
+                       for (ALL_LIST_ELEMENTS_RO(
+                                               bgp->vpn_policy[afi].export_vrf,
+                                               node, vname))
+                               vty_out(vty, "  %s\n", vname);
+
+                       vty_out(vty, "RD: %s\n",
+                               prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd,
+                                             buf1, RD_ADDRSTRLEN));
+
+                       dir = BGP_VPN_POLICY_DIR_TOVPN;
+                       ecom_str = ecommunity_ecom2str(
+                                       bgp->vpn_policy[afi].rtlist[dir],
+                                       ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
+                       vty_out(vty, "Export RT: %s\n", ecom_str);
+                       XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
                }
-               vty_out(vty, "RD: %s\n",
-                       prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd,
-                                     buf1, RD_ADDRSTRLEN));
-               dir = BGP_VPN_POLICY_DIR_TOVPN;
-               ecom_str = ecommunity_ecom2str(
-                               bgp->vpn_policy[afi].rtlist[dir],
-                               ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
-               vty_out(vty, "Emport RT: %s\n", ecom_str);
-               XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);
        }
 
        return CMD_SUCCESS;
@@ -11069,20 +11153,22 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name,
 
 /* "show [ip] bgp route-leak" command.  */
 DEFUN (show_ip_bgp_route_leak,
-       show_ip_bgp_route_leak_cmd,
-       "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak",
-       SHOW_STR
-       IP_STR
-       BGP_STR
-       BGP_INSTANCE_HELP_STR
-       BGP_AFI_HELP_STR
-       BGP_SAFI_HELP_STR
-       "Route leaking information\n")
+       show_ip_bgp_route_leak_cmd,
+       "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak  [json]",
+       SHOW_STR
+       IP_STR
+       BGP_STR
+       BGP_INSTANCE_HELP_STR
+       BGP_AFI_HELP_STR
+       BGP_SAFI_HELP_STR
+       "Route leaking information\n"
+       JSON_STR)
 {
        char *vrf = NULL;
        afi_t afi = AFI_MAX;
        safi_t safi = SAFI_MAX;
 
+       uint8_t uj = use_json(argc, argv);
        int idx = 0;
 
        /* show [ip] bgp */
@@ -11110,7 +11196,7 @@ DEFUN (show_ip_bgp_route_leak,
                return CMD_WARNING;
        }
 
-       return bgp_show_route_leak_vty(vty, vrf, afi, safi);
+       return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj);
 }
 
 static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi,
index 3a6c80297eb5a929e895a38f36e701755dbbb9e0..086238eda544ceb7c54ddef22f136881d693daca 100755 (executable)
@@ -10,7 +10,6 @@
 WANT_LDP ?= 1
 WANT_PIM ?= 1
 WANT_OSPFAPI ?= 1
-WANT_TCP_ZEBRA ?= 0
 WANT_BGP_VNC ?= 1
 WANT_CUMULUS_MODE ?= 0
 WANT_MULTIPATH ?= 1
@@ -65,12 +64,6 @@ else
   USE_OSPFAPI=--enable-ospfapi=no
 endif
 
-ifeq ($(WANT_TCP_ZEBRA),1)
-  USE_TCP_ZEBRA=--enable-tcp-zebra
-else
-  USE_TCP_ZEBRA=--disable-tcp-zebra
-endif
-
 ifeq ($(WANT_BGP_VNC), 1)
   USE_BGP_VNC=--enable-bgp-vnc=yes
 else
@@ -123,7 +116,6 @@ override_dh_auto_configure:
                $(USE_OSPFAPI) \
                $(USE_MULTIPATH) \
                $(USE_LDP) \
-               $(USE_TCP_ZEBRA) \
                --enable-fpm \
                $(USE_FRR_USER) $(USE_FRR_GROUP) \
                $(USE_FRR_VTY_GROUP) \
index f7468d6f791fc16218dcc9e1d86e78af2a957f30..559a27e25617e5ab4062f8941c22c8674da49739 100755 (executable)
@@ -10,7 +10,6 @@
 WANT_LDP ?= 1
 WANT_PIM ?= 1
 WANT_OSPFAPI ?= 1
-WANT_TCP_ZEBRA ?= 0
 WANT_BGP_VNC ?= 1
 WANT_CUMULUS_MODE ?= 0
 WANT_MULTIPATH ?= 1
@@ -75,12 +74,6 @@ else
   USE_OSPFAPI=--enable-ospfapi=no
 endif
 
-ifeq ($(WANT_TCP_ZEBRA),1)
-  USE_TCP_ZEBRA=--enable-tcp-zebra
-else
-  USE_TCP_ZEBRA=--disable-tcp-zebra
-endif
-
 ifeq ($(WANT_BGP_VNC), 1)
   USE_BGP_VNC=--enable-bgp-vnc=yes
 else
@@ -152,7 +145,6 @@ override_dh_auto_configure:
                $(USE_OSPFAPI) \
                $(USE_MULTIPATH) \
                $(USE_LDP) \
-               $(USE_TCP_ZEBRA) \
                --enable-fpm \
                $(USE_FRR_USER) $(USE_FRR_GROUP) \
                $(USE_FRR_VTY_GROUP) \
index c1cb865490f3a2bad277cb66e1226e3019c57a1b..28d291e40abca8bffc5ea23a60bea1034849faf4 100755 (executable)
@@ -10,7 +10,6 @@
 WANT_LDP ?= 1
 WANT_PIM ?= 1
 WANT_OSPFAPI ?= 1
-WANT_TCP_ZEBRA ?= 0
 WANT_BGP_VNC ?= 1
 WANT_CUMULUS_MODE ?= 0
 WANT_MULTIPATH ?= 1
@@ -75,12 +74,6 @@ else
   USE_OSPFAPI=--enable-ospfapi=no
 endif
 
-ifeq ($(WANT_TCP_ZEBRA),1)
-  USE_TCP_ZEBRA=--enable-tcp-zebra
-else
-  USE_TCP_ZEBRA=--disable-tcp-zebra
-endif
-
 ifeq ($(WANT_BGP_VNC), 1)
   USE_BGP_VNC=--enable-bgp-vnc=yes
 else
@@ -152,7 +145,6 @@ override_dh_auto_configure:
                $(USE_OSPFAPI) \
                $(USE_MULTIPATH) \
                $(USE_LDP) \
-               $(USE_TCP_ZEBRA) \
                --enable-fpm \
                $(USE_FRR_USER) $(USE_FRR_GROUP) \
                $(USE_FRR_VTY_GROUP) \
index 1e99010505b405d4e142fb22a45b2ce6e316c6b0..5fff6fca6651cd6014b6ca42da0b745ce1357269 100644 (file)
@@ -126,7 +126,7 @@ These following options control the daemon's VTY (interactive command line) inte
       staticd         2616
       bfdd            2617
 
-   Port 2607 is used for ospfd's Opaque LSA API, while port 2600 is used for the (insecure) TCP-ZEBRA interface.
+   Port 2607 is used for ospfd's Opaque LSA API.
 
 .. option:: --vty_socket vty-path
 
index e95dd26e84bbacddf0f91514dcc3bc891396baa7..c62835c7701f3588a63902459e0d92b0f775e5ce 100644 (file)
@@ -6,6 +6,7 @@
 .. toctree::
    :maxdepth: 2
 
+   bfdd
    bgpd
    eigrpd
    isisd
index 8eb9efe789e9b357fbc8e6cf375aef75bc687a32..986d1494a5476a782c2cb507bea660f61749082b 100644 (file)
@@ -179,7 +179,7 @@ The following commands are available inside the BGP configuration node.
 .. _bfd-ospf-peer-config:
 
 OSPF BFD Configuration
----------------------
+----------------------
 
 The following commands are available inside the interface configuration node.
 
@@ -364,7 +364,7 @@ You can inspect the current BFD peer status with the following commands:
                            Echo transmission interval: 50ms
 
    frr# show bfd peer 192.168.0.1 json
-{"multihop":false,"peer":"192.168.0.1","id":1,"remote-id":1,"status":"up","uptime":161,"diagnostic":"ok","remote-diagnostic":"ok","receive-interval":300,"transmit-interval":300,"echo-interval":50,"remote-receive-interval":300,"remote-transmit-interval":300,"remote-echo-interval":50}
+   {"multihop":false,"peer":"192.168.0.1","id":1,"remote-id":1,"status":"up","uptime":161,"diagnostic":"ok","remote-diagnostic":"ok","receive-interval":300,"transmit-interval":300,"echo-interval":50,"remote-receive-interval":300,"remote-transmit-interval":300,"remote-echo-interval":50}
 
 
 You can also inspect peer session counters with the following commands:
@@ -402,4 +402,4 @@ You can also inspect peer session counters with the following commands:
                 Zebra notifications: 4
 
    frr# show bfd peer 192.168.0.1 counters json
-{"multihop":false,"peer":"192.168.0.1","control-packet-input":348,"control-packet-output":685,"echo-packet-input":6815,"echo-packet-output":6816,"session-up":1,"session-down":0,"zebra-notifications":4}
+   {"multihop":false,"peer":"192.168.0.1","control-packet-input":348,"control-packet-output":685,"echo-packet-input":6815,"echo-packet-output":6816,"session-up":1,"session-down":0,"zebra-notifications":4}
index 2fa5db6f34fb1ec20add64f60c5f39985c6b8acd..d1b9d514b468e8d7d63159644d0b68e3ef0efa38 100644 (file)
@@ -146,7 +146,7 @@ void log_ref_display(struct vty *vty, uint32_t code, bool json)
                        char ubuf[256];
 
                        snprintf(pbuf, sizeof(pbuf), "\nError %"PRIu32" - %s",
-                                code, ref->title);
+                                ref->code, ref->title);
                        memset(ubuf, '=', strlen(pbuf));
                        ubuf[sizeof(ubuf) - 1] = '\0';
 
index e011a78f1c3a38e4b267aab9e0a1e1f9e65ef20e..361521f56823335f749f3aa059ed62efedb8939e 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -868,11 +868,16 @@ int zlog_rotate(void)
                save_errno = errno;
                umask(oldumask);
                if (zl->fp == NULL) {
+
+                       pthread_mutex_unlock(&loglock);
+
                        flog_err_sys(
                                LIB_ERR_SYSTEM_CALL,
                                "Log rotate failed: cannot open file %s for append: %s",
                                zl->filename, safe_strerror(save_errno));
                        ret = -1;
+
+                       pthread_mutex_lock(&loglock);
                } else {
                        logfile_fd = fileno(zl->fp);
                        zl->maxlvl[ZLOG_DEST_FILE] = level;
index 2059d8486829c099daf136c1b853df2d8e418fc0..0828c2beb659348d24b47305d0ae9f8f1f87a2ac 100644 (file)
@@ -330,6 +330,8 @@ void ospf6_flood_interface(struct ospf6_neighbor *from, struct ospf6_lsa *lsa,
                                                zlog_debug(
                                                        "Requesting the same, remove it, next neighbor");
                                        if (req == on->last_ls_req) {
+                                               /* sanity check refcount */
+                                               assert(req->lock >= 2);
                                                ospf6_lsa_unlock(req);
                                                on->last_ls_req = NULL;
                                        }
index db624ae0741aaefaae71579a15e8198e6a8fb20f..50485cc7e25c334de1a40787e945d3809c8b13c0 100644 (file)
@@ -46,6 +46,7 @@
 #include "ospfd/ospf_lsdb.h"
 #include "ospfd/ospf_neighbor.h"
 #include "ospfd/ospf_dump.h"
+#include "ospfd/ospf_route.h"
 #include "ospfd/ospf_zebra.h"
 #include "ospfd/ospf_api.h"
 
index c0ce971f0cbd6fd5d7520a2096e934fbb6f9ffb1..57e0ae5ec95f83c95b3323c119483d103dd782b7 100644 (file)
@@ -1425,19 +1425,7 @@ struct ospf_lsa *ospf_apiserver_opaque_lsa_new(struct ospf_area *area,
        newlsa->length = htons(length);
 
        /* Create OSPF LSA. */
-       if ((new = ospf_lsa_new()) == NULL) {
-               zlog_warn("ospf_apiserver_opaque_lsa_new: ospf_lsa_new() ?");
-               stream_free(s);
-               return NULL;
-       }
-
-       if ((new->data = ospf_lsa_data_new(length)) == NULL) {
-               zlog_warn(
-                       "ospf_apiserver_opaque_lsa_new: ospf_lsa_data_new() ?");
-               ospf_lsa_unlock(&new);
-               stream_free(s);
-               return NULL;
-       }
+       new = ospf_lsa_new_and_data(length);
 
        new->area = area;
        new->oi = oi;
index 18c1077da09427e2698968a89e5573b471002a04..8e8f65530529e5f4319973337c602385045582a5 100644 (file)
@@ -73,26 +73,6 @@ void ospf_external_route_remove(struct ospf *ospf, struct prefix_ipv4 *p)
                  p->prefixlen);
 }
 
-/* Lookup external route. */
-struct ospf_route *ospf_external_route_lookup(struct ospf *ospf,
-                                             struct prefix_ipv4 *p)
-{
-       struct route_node *rn;
-
-       rn = route_node_lookup(ospf->old_external_route, (struct prefix *)p);
-       if (rn) {
-               route_unlock_node(rn);
-               if (rn->info)
-                       return rn->info;
-       }
-
-       zlog_warn("Route[%s/%d]: lookup, no such prefix", inet_ntoa(p->prefix),
-                 p->prefixlen);
-
-       return NULL;
-}
-
-
 /* Add an External info for AS-external-LSA. */
 struct external_info *ospf_external_info_new(uint8_t type,
                                             unsigned short instance)
index 370c6787b4153c8cdb49e53d33d5904f43a76a67..ac7bd68b5f3d7cb9cd20ce341b21efdf1338dcf5 100644 (file)
@@ -68,8 +68,6 @@ extern void ospf_external_info_delete(struct ospf *, uint8_t, unsigned short,
 extern struct external_info *ospf_external_info_lookup(struct ospf *, uint8_t,
                                                       unsigned short,
                                                       struct prefix_ipv4 *);
-extern struct ospf_route *ospf_external_route_lookup(struct ospf *,
-                                                    struct prefix_ipv4 *);
 extern void ospf_asbr_status_update(struct ospf *, uint8_t);
 
 extern void ospf_redistribute_withdraw(struct ospf *, uint8_t, unsigned short);
index b8d14c351ee38b1a82aa494fac7dead90144ccbc..f6ed9b81b964d04915f6f9b9f01e64e7998be741 100644 (file)
@@ -977,20 +977,7 @@ static struct ospf_lsa *ospf_ext_pref_lsa_new(struct ospf_area *area,
        lsah->length = htons(length);
 
        /* Now, create an OSPF LSA instance. */
-       new = ospf_lsa_new();
-       if (new == NULL) {
-               zlog_warn("EXT (%s): ospf_lsa_new() error", __func__);
-               stream_free(s);
-               return NULL;
-       }
-       new->data = ospf_lsa_data_new(length);
-       if (new->data == NULL) {
-               zlog_warn("EXT (%s): ospf_lsa_data_new() error", __func__);
-               ospf_lsa_unlock(&new);
-               new = NULL;
-               stream_free(s);
-               return NULL;
-       }
+       new = ospf_lsa_new_and_data(length);
 
        /* Segment Routing belongs only to default VRF */
        new->vrf_id = VRF_DEFAULT;
@@ -1056,20 +1043,7 @@ static struct ospf_lsa *ospf_ext_link_lsa_new(struct ospf_area *area,
        lsah->length = htons(length);
 
        /* Now, create an OSPF LSA instance. */
-       new = ospf_lsa_new();
-       if (new == NULL) {
-               zlog_warn("EXT (%s): ospf_lsa_new() error", __func__);
-               stream_free(s);
-               return NULL;
-       }
-       new->data = ospf_lsa_data_new(length);
-       if (new->data == NULL) {
-               zlog_warn("EXT (%s): ospf_lsa_data_new() error", __func__);
-               ospf_lsa_unlock(&new);
-               new = NULL;
-               stream_free(s);
-               return NULL;
-       }
+       new = ospf_lsa_new_and_data(length);
 
        /* Segment Routing belongs only to default VRF */
        new->vrf_id = VRF_DEFAULT;
index 002c6bba8d7023a52743955ed84b09466c538be5..b4e9dda58a106f51347399df61be7d0cad0caf03 100644 (file)
@@ -810,8 +810,7 @@ struct ospf_lsa *ospf_ls_request_new(struct lsa_header *lsah)
 {
        struct ospf_lsa *new;
 
-       new = ospf_lsa_new();
-       new->data = ospf_lsa_data_new(OSPF_LSA_HEADER_SIZE);
+       new = ospf_lsa_new_and_data(OSPF_LSA_HEADER_SIZE);
        memcpy(new->data, lsah, OSPF_LSA_HEADER_SIZE);
 
        return new;
index 2651cf717b82355c9d83190db21752394ec795be..47d8b2f57a73a6bda2bcd94dee26b23287d54fbd 100644 (file)
@@ -167,6 +167,16 @@ struct ospf_lsa *ospf_lsa_new()
        return new;
 }
 
+struct ospf_lsa *ospf_lsa_new_and_data(size_t size)
+{
+       struct ospf_lsa *new;
+
+       new = ospf_lsa_new();
+       new->data = ospf_lsa_data_new(size);
+
+       return new;
+}
+
 /* Duplicate OSPF LSA. */
 struct ospf_lsa *ospf_lsa_dup(struct ospf_lsa *lsa)
 {
@@ -781,17 +791,13 @@ static struct ospf_lsa *ospf_router_lsa_new(struct ospf_area *area)
        lsah->length = htons(length);
 
        /* Now, create OSPF LSA instance. */
-       if ((new = ospf_lsa_new()) == NULL) {
-               zlog_err("%s: Unable to create new lsa", __func__);
-               return NULL;
-       }
+       new = ospf_lsa_new_and_data(length);
 
        new->area = area;
        SET_FLAG(new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
        new->vrf_id = area->ospf->vrf_id;
 
        /* Copy LSA data to store, discard stream. */
-       new->data = ospf_lsa_data_new(length);
        memcpy(new->data, lsah, length);
        stream_free(s);
 
@@ -997,17 +1003,13 @@ static struct ospf_lsa *ospf_network_lsa_new(struct ospf_interface *oi)
        lsah->length = htons(length);
 
        /* Create OSPF LSA instance. */
-       if ((new = ospf_lsa_new()) == NULL) {
-               zlog_err("%s: ospf_lsa_new returned NULL", __func__);
-               return NULL;
-       }
+       new = ospf_lsa_new_and_data(length);
 
        new->area = oi->area;
        SET_FLAG(new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
        new->vrf_id = oi->ospf->vrf_id;
 
        /* Copy LSA to store. */
-       new->data = ospf_lsa_data_new(length);
        memcpy(new->data, lsah, length);
        stream_free(s);
 
@@ -1181,13 +1183,12 @@ static struct ospf_lsa *ospf_summary_lsa_new(struct ospf_area *area,
        lsah->length = htons(length);
 
        /* Create OSPF LSA instance. */
-       new = ospf_lsa_new();
+       new = ospf_lsa_new_and_data(length);
        new->area = area;
        SET_FLAG(new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
        new->vrf_id = area->ospf->vrf_id;
 
        /* Copy LSA to store. */
-       new->data = ospf_lsa_data_new(length);
        memcpy(new->data, lsah, length);
        stream_free(s);
 
@@ -1323,13 +1324,12 @@ static struct ospf_lsa *ospf_summary_asbr_lsa_new(struct ospf_area *area,
        lsah->length = htons(length);
 
        /* Create OSPF LSA instance. */
-       new = ospf_lsa_new();
+       new = ospf_lsa_new_and_data(length);
        new->area = area;
        SET_FLAG(new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
        new->vrf_id = area->ospf->vrf_id;
 
        /* Copy LSA to store. */
-       new->data = ospf_lsa_data_new(length);
        memcpy(new->data, lsah, length);
        stream_free(s);
 
@@ -1629,14 +1629,13 @@ static struct ospf_lsa *ospf_external_lsa_new(struct ospf *ospf,
        lsah->length = htons(length);
 
        /* Now, create OSPF LSA instance. */
-       new = ospf_lsa_new();
+       new = ospf_lsa_new_and_data(length);
        new->area = NULL;
        SET_FLAG(new->flags,
                 OSPF_LSA_SELF | OSPF_LSA_APPROVED | OSPF_LSA_SELF_CHECKED);
        new->vrf_id = ospf->vrf_id;
 
        /* Copy LSA data to store, discard stream. */
-       new->data = ospf_lsa_data_new(length);
        memcpy(new->data, lsah, length);
        stream_free(s);
 
index f8f7b28d4ed1a17c7d8bd4c903aae5c7e86cea14..ba4c4c1cacf7e2489e42ffc5046017f039039151 100644 (file)
@@ -235,6 +235,7 @@ extern int ospf_check_nbr_status(struct ospf *);
 
 /* Prototype for LSA primitive. */
 extern struct ospf_lsa *ospf_lsa_new(void);
+extern struct ospf_lsa *ospf_lsa_new_and_data(size_t size);
 extern struct ospf_lsa *ospf_lsa_dup(struct ospf_lsa *);
 extern void ospf_lsa_free(struct ospf_lsa *);
 extern struct ospf_lsa *ospf_lsa_lock(struct ospf_lsa *);
index 6dadc05bbab42bcaa95d84d3ae5479ba3f3a2df8..8853802d07e58b3ab1d1f57d08e91eb166589091 100644 (file)
@@ -49,6 +49,7 @@
 #include "ospfd/ospf_lsdb.h"
 #include "ospfd/ospf_neighbor.h"
 #include "ospfd/ospf_dump.h"
+#include "ospfd/ospf_route.h"
 #include "ospfd/ospf_zebra.h"
 #include "ospfd/ospf_vty.h"
 #include "ospfd/ospf_bfd.h"
index f1d4a39dba82d06e1262e26ebbd522bd907918dd..56b83d22d5b7ca9f84d41f1de34959999b4737cb 100644 (file)
@@ -1742,7 +1742,7 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr,
                }
 
                /* Create OSPF LSA instance. */
-               lsa = ospf_lsa_new();
+               lsa = ospf_lsa_new_and_data(length);
 
                lsa->vrf_id = oi->ospf->vrf_id;
                /* We may wish to put some error checking if type NSSA comes in
@@ -1761,7 +1761,6 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr,
                        break;
                }
 
-               lsa->data = ospf_lsa_data_new(length);
                memcpy(lsa->data, lsah, length);
 
                if (IS_DEBUG_OSPF_EVENT)
index fa7dd04d19f800f6a48a408a7eb8fbb7330dff1a..c9d0a53c8dc1cf42c7504866d4fb8b2ab808508c 100644 (file)
@@ -775,18 +775,7 @@ static struct ospf_lsa *ospf_router_info_lsa_new()
        lsah->length = htons(length);
 
        /* Now, create an OSPF LSA instance. */
-       if ((new = ospf_lsa_new()) == NULL) {
-               zlog_warn("ospf_router_info_lsa_new: ospf_lsa_new() ?");
-               stream_free(s);
-               return NULL;
-       }
-       if ((new->data = ospf_lsa_data_new(length)) == NULL) {
-               zlog_warn("ospf_router_info_lsa_new: ospf_lsa_data_new() ?");
-               ospf_lsa_unlock(&new);
-               new = NULL;
-               stream_free(s);
-               return new;
-       }
+       new = ospf_lsa_new_and_data(length);
 
        new->area = OspfRI.area; /* Area must be null if the Opaque type is AS
                                    scope, fulfill otherwise */
index c90db031dcf2f2137687d2cf81da53bc8e122980..19d2e6a95251f4fb1de862a5c56bda0105842370 100644 (file)
@@ -47,6 +47,7 @@
 #include "ospfd/ospf_flood.h"
 #include "ospfd/ospf_ism.h"
 #include "ospfd/ospf_dump.h"
+#include "ospfd/ospf_route.h"
 #include "ospfd/ospf_zebra.h"
 
 /* OSPF2-MIB. */
index cc2d9282fe14c024427fef124a237345364ba7b4..a9dc1c18e392e110701acbbdc991215a6bf25fd7 100644 (file)
@@ -1201,18 +1201,7 @@ static struct ospf_lsa *ospf_mpls_te_lsa_new(struct ospf *ospf,
        lsah->length = htons(length);
 
        /* Now, create an OSPF LSA instance. */
-       if ((new = ospf_lsa_new()) == NULL) {
-               zlog_warn("%s: ospf_lsa_new() ?", __func__);
-               stream_free(s);
-               return NULL;
-       }
-       if ((new->data = ospf_lsa_data_new(length)) == NULL) {
-               zlog_warn("%s: ospf_lsa_data_new() ?", __func__);
-               ospf_lsa_unlock(&new);
-               new = NULL;
-               stream_free(s);
-               return new;
-       }
+       new = ospf_lsa_new_and_data(length);
 
        new->vrf_id = ospf->vrf_id;
        if (area && area->ospf)
index ac8f0d92c322b988aa9a331676603185e2878269..bfaedf2fe70236495ac6906007a923df275017f2 100644 (file)
 #include "ospfd/ospf_spf.h"
 #include "ospfd/ospf_packet.h"
 #include "ospfd/ospf_dump.h"
+#include "ospfd/ospf_route.h"
 #include "ospfd/ospf_zebra.h"
 #include "ospfd/ospf_abr.h"
 #include "ospfd/ospf_flood.h"
-#include "ospfd/ospf_route.h"
 #include "ospfd/ospf_ase.h"