diff options
| -rw-r--r-- | bgpd/bgp_vty.c | 198 | ||||
| -rwxr-xr-x | debianpkg/backports/ubuntu12.04/debian/rules | 8 | ||||
| -rwxr-xr-x | debianpkg/backports/ubuntu14.04/debian/rules | 8 | ||||
| -rwxr-xr-x | debianpkg/rules | 8 | ||||
| -rw-r--r-- | doc/manpages/common-options.rst | 2 | ||||
| -rw-r--r-- | doc/manpages/index.rst | 1 | ||||
| -rw-r--r-- | doc/user/bfd.rst | 6 | ||||
| -rw-r--r-- | lib/ferr.c | 2 | ||||
| -rw-r--r-- | lib/log.c | 5 | ||||
| -rw-r--r-- | ospf6d/ospf6_flood.c | 2 | ||||
| -rw-r--r-- | ospfclient/ospf_apiclient.c | 1 | ||||
| -rw-r--r-- | ospfd/ospf_apiserver.c | 14 | ||||
| -rw-r--r-- | ospfd/ospf_asbr.c | 20 | ||||
| -rw-r--r-- | ospfd/ospf_asbr.h | 2 | ||||
| -rw-r--r-- | ospfd/ospf_ext.c | 30 | ||||
| -rw-r--r-- | ospfd/ospf_flood.c | 3 | ||||
| -rw-r--r-- | ospfd/ospf_lsa.c | 31 | ||||
| -rw-r--r-- | ospfd/ospf_lsa.h | 1 | ||||
| -rw-r--r-- | ospfd/ospf_main.c | 1 | ||||
| -rw-r--r-- | ospfd/ospf_packet.c | 3 | ||||
| -rw-r--r-- | ospfd/ospf_ri.c | 13 | ||||
| -rw-r--r-- | ospfd/ospf_snmp.c | 1 | ||||
| -rw-r--r-- | ospfd/ospf_te.c | 13 | ||||
| -rw-r--r-- | ospfd/ospfd.c | 2 |
24 files changed, 182 insertions, 193 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index fda458cb84..98d9ffcceb 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -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, diff --git a/debianpkg/backports/ubuntu12.04/debian/rules b/debianpkg/backports/ubuntu12.04/debian/rules index 3a6c80297e..086238eda5 100755 --- a/debianpkg/backports/ubuntu12.04/debian/rules +++ b/debianpkg/backports/ubuntu12.04/debian/rules @@ -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) \ diff --git a/debianpkg/backports/ubuntu14.04/debian/rules b/debianpkg/backports/ubuntu14.04/debian/rules index f7468d6f79..559a27e256 100755 --- a/debianpkg/backports/ubuntu14.04/debian/rules +++ b/debianpkg/backports/ubuntu14.04/debian/rules @@ -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) \ diff --git a/debianpkg/rules b/debianpkg/rules index c1cb865490..28d291e40a 100755 --- a/debianpkg/rules +++ b/debianpkg/rules @@ -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) \ diff --git a/doc/manpages/common-options.rst b/doc/manpages/common-options.rst index 1e99010505..5fff6fca66 100644 --- a/doc/manpages/common-options.rst +++ b/doc/manpages/common-options.rst @@ -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 diff --git a/doc/manpages/index.rst b/doc/manpages/index.rst index e95dd26e84..c62835c770 100644 --- a/doc/manpages/index.rst +++ b/doc/manpages/index.rst @@ -6,6 +6,7 @@ .. toctree:: :maxdepth: 2 + bfdd bgpd eigrpd isisd diff --git a/doc/user/bfd.rst b/doc/user/bfd.rst index 8eb9efe789..986d1494a5 100644 --- a/doc/user/bfd.rst +++ b/doc/user/bfd.rst @@ -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} diff --git a/lib/ferr.c b/lib/ferr.c index 2fa5db6f34..d1b9d514b4 100644 --- a/lib/ferr.c +++ b/lib/ferr.c @@ -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'; @@ -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; diff --git a/ospf6d/ospf6_flood.c b/ospf6d/ospf6_flood.c index 2059d84868..0828c2beb6 100644 --- a/ospf6d/ospf6_flood.c +++ b/ospf6d/ospf6_flood.c @@ -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; } diff --git a/ospfclient/ospf_apiclient.c b/ospfclient/ospf_apiclient.c index db624ae074..50485cc7e2 100644 --- a/ospfclient/ospf_apiclient.c +++ b/ospfclient/ospf_apiclient.c @@ -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" diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c index c0ce971f0c..57e0ae5ec9 100644 --- a/ospfd/ospf_apiserver.c +++ b/ospfd/ospf_apiserver.c @@ -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; diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c index 18c1077da0..8e8f655305 100644 --- a/ospfd/ospf_asbr.c +++ b/ospfd/ospf_asbr.c @@ -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) diff --git a/ospfd/ospf_asbr.h b/ospfd/ospf_asbr.h index 370c6787b4..ac7bd68b5f 100644 --- a/ospfd/ospf_asbr.h +++ b/ospfd/ospf_asbr.h @@ -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); diff --git a/ospfd/ospf_ext.c b/ospfd/ospf_ext.c index b8d14c351e..f6ed9b81b9 100644 --- a/ospfd/ospf_ext.c +++ b/ospfd/ospf_ext.c @@ -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; diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c index 002c6bba8d..b4e9dda58a 100644 --- a/ospfd/ospf_flood.c +++ b/ospfd/ospf_flood.c @@ -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; diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 2651cf717b..47d8b2f57a 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -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); diff --git a/ospfd/ospf_lsa.h b/ospfd/ospf_lsa.h index f8f7b28d4e..ba4c4c1cac 100644 --- a/ospfd/ospf_lsa.h +++ b/ospfd/ospf_lsa.h @@ -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 *); diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index 6dadc05bba..8853802d07 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -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" diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index f1d4a39dba..56b83d22d5 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -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) diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c index fa7dd04d19..c9d0a53c8d 100644 --- a/ospfd/ospf_ri.c +++ b/ospfd/ospf_ri.c @@ -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 */ diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index c90db031dc..19d2e6a952 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -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. */ diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index cc2d9282fe..a9dc1c18e3 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -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) diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index ac8f0d92c3..bfaedf2fe7 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -52,10 +52,10 @@ #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" |
