summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_attr.c5
-rw-r--r--bgpd/bgp_encap.c14
-rw-r--r--bgpd/bgp_mplsvpn.c57
-rw-r--r--bgpd/bgp_route.c44
-rw-r--r--lib/privs.c4
-rw-r--r--ospf6d/ospf6_intra.c3
-rw-r--r--ospfd/ospf_abr.c9
-rw-r--r--ospfd/ospf_interface.c4
-rw-r--r--ospfd/ospf_interface.h12
-rw-r--r--ospfd/ospf_vty.c114
-rw-r--r--ospfd/ospf_vty.h7
-rw-r--r--ospfd/ospfd.c39
-rw-r--r--ospfd/ospfd.h14
-rw-r--r--pimd/pim_cmd.c2
14 files changed, 169 insertions, 159 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 61dcbd1b29..5fe8ebb67f 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -2918,7 +2918,8 @@ bgp_packet_mpattr_tea(
case BGP_ATTR_ENCAP:
attrname = "Tunnel Encap";
subtlvs = attr->extra->encap_subtlvs;
-
+ if (subtlvs == NULL) /* nothing to do */
+ return;
/*
* The tunnel encap attr has an "outer" tlv.
* T = tunneltype,
@@ -2933,6 +2934,8 @@ bgp_packet_mpattr_tea(
case BGP_ATTR_VNC:
attrname = "VNC";
subtlvs = attr->extra->vnc_subtlvs;
+ if (subtlvs == NULL) /* nothing to do */
+ return;
attrlenfield = 0; /* no outer T + L */
attrhdrlen = 2 + 2; /* subTLV T + L */
break;
diff --git a/bgpd/bgp_encap.c b/bgpd/bgp_encap.c
index 01df053952..060f5afb4c 100644
--- a/bgpd/bgp_encap.c
+++ b/bgpd/bgp_encap.c
@@ -208,25 +208,22 @@ bgp_nlri_parse_encap(
/* For testing purpose, static route of ENCAP. */
DEFUN (encap_network,
encap_network_cmd,
- "network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
+ "network A.B.C.D/M rd ASN:nn_or_IP-address:nn",
"Specify a network to announce via BGP\n"
"IPv4 prefix\n"
"Specify Route Distinguisher\n"
- "ENCAP Route Distinguisher\n"
- "BGP tag\n"
- "tag value\n")
+ "ENCAP Route Distinguisher\n")
{
int idx_ipv4 = 1;
int idx_rd = 3;
- int idx_word = 5;
- return bgp_static_set_safi (AFI_IP, SAFI_ENCAP, vty, argv[idx_ipv4]->arg, argv[idx_rd]->arg, argv[idx_word]->arg,
+ return bgp_static_set_safi (AFI_IP, SAFI_ENCAP, vty, argv[idx_ipv4]->arg, argv[idx_rd]->arg, NULL,
NULL, 0, NULL, NULL, NULL, NULL);
}
/* For testing purpose, static route of ENCAP. */
DEFUN (no_encap_network,
no_encap_network_cmd,
- "no network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
+ "no network A.B.C.D/M rd ASN:nn_or_IP-address:nn",
NO_STR
"Specify a network to announce via BGP\n"
"IPv4 prefix\n"
@@ -237,8 +234,7 @@ DEFUN (no_encap_network,
{
int idx_ipv4 = 2;
int idx_rd = 4;
- int idx_word = 6;
- return bgp_static_unset_safi (AFI_IP, SAFI_ENCAP, vty, argv[idx_ipv4]->arg, argv[idx_rd]->arg, argv[idx_word]->arg,
+ return bgp_static_unset_safi (AFI_IP, SAFI_ENCAP, vty, argv[idx_ipv4]->arg, argv[idx_rd]->arg, NULL,
0, NULL, NULL, NULL);
}
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 60a48f506b..4a8bfed8bb 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -460,99 +460,104 @@ prefix_rd2str (struct prefix_rd *prd, char *buf, size_t size)
/* For testing purpose, static route of MPLS-VPN. */
DEFUN (vpnv4_network,
vpnv4_network_cmd,
- "network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
+ "network A.B.C.D/M rd ASN:nn_or_IP-address:nn <tag|label> (0-1048575)",
"Specify a network to announce via BGP\n"
"IPv4 prefix\n"
"Specify Route Distinguisher\n"
"VPN Route Distinguisher\n"
- "BGP tag\n"
- "tag value\n")
+ "VPN NLRI label (tag)\n"
+ "VPN NLRI label (tag)\n"
+ "Label value\n")
{
int idx_ipv4_prefixlen = 1;
int idx_ext_community = 3;
- int idx_word = 5;
+ int idx_label = 5;
return bgp_static_set_safi (AFI_IP, SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg,
- argv[idx_word]->arg, NULL, 0, NULL, NULL, NULL, NULL);
+ argv[idx_label]->arg, NULL, 0, NULL, NULL, NULL, NULL);
}
DEFUN (vpnv4_network_route_map,
vpnv4_network_route_map_cmd,
- "network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD route-map WORD",
+ "network A.B.C.D/M rd ASN:nn_or_IP-address:nn <tag|label> (0-1048575) route-map WORD",
"Specify a network to announce via BGP\n"
"IPv4 prefix\n"
"Specify Route Distinguisher\n"
"VPN Route Distinguisher\n"
- "BGP tag\n"
- "tag value\n"
+ "VPN NLRI label (tag)\n"
+ "VPN NLRI label (tag)\n"
+ "Label value\n"
"route map\n"
"route map name\n")
{
int idx_ipv4_prefixlen = 1;
int idx_ext_community = 3;
- int idx_word = 5;
+ int idx_label = 5;
int idx_word_2 = 7;
- return bgp_static_set_safi (AFI_IP, SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg,
+ return bgp_static_set_safi (AFI_IP, SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_label]->arg,
argv[idx_word_2]->arg, 0, NULL, NULL, NULL, NULL);
}
/* For testing purpose, static route of MPLS-VPN. */
DEFUN (no_vpnv4_network,
no_vpnv4_network_cmd,
- "no network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
+ "no network A.B.C.D/M rd ASN:nn_or_IP-address:nn <tag|label> (0-1048575)",
NO_STR
"Specify a network to announce via BGP\n"
"IPv4 prefix\n"
"Specify Route Distinguisher\n"
"VPN Route Distinguisher\n"
- "BGP tag\n"
- "tag value\n")
+ "VPN NLRI label (tag)\n"
+ "VPN NLRI label (tag)\n"
+ "Label value\n")
{
int idx_ipv4_prefixlen = 2;
int idx_ext_community = 4;
- int idx_word = 6;
+ int idx_label = 6;
return bgp_static_unset_safi (AFI_IP, SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg,
- argv[idx_ext_community]->arg, argv[idx_word]->arg,
+ argv[idx_ext_community]->arg, argv[idx_label]->arg,
0, NULL, NULL, NULL);
}
DEFUN (vpnv6_network,
vpnv6_network_cmd,
- "network X:X::X:X/M rd ASN:nn_or_IP-address:nn tag WORD [route-map WORD]",
+ "network X:X::X:X/M rd ASN:nn_or_IP-address:nn <tag|label> (0-1048575) [route-map WORD]",
"Specify a network to announce via BGP\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Specify Route Distinguisher\n"
"VPN Route Distinguisher\n"
- "BGP tag\n"
- "tag value\n"
+ "VPN NLRI label (tag)\n"
+ "VPN NLRI label (tag)\n"
+ "Label value\n"
"route map\n"
"route map name\n")
{
int idx_ipv6_prefix = 1;
int idx_ext_community = 3;
- int idx_word = 5;
+ int idx_label = 5;
int idx_word_2 = 7;
if (argc == 8)
- return bgp_static_set_safi (AFI_IP6, SAFI_MPLS_VPN, vty, argv[idx_ipv6_prefix]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, argv[idx_word_2]->arg, 0, NULL, NULL, NULL, NULL);
+ return bgp_static_set_safi (AFI_IP6, SAFI_MPLS_VPN, vty, argv[idx_ipv6_prefix]->arg, argv[idx_ext_community]->arg, argv[idx_label]->arg, argv[idx_word_2]->arg, 0, NULL, NULL, NULL, NULL);
else
- return bgp_static_set_safi (AFI_IP6, SAFI_MPLS_VPN, vty, argv[idx_ipv6_prefix]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, NULL, 0, NULL, NULL, NULL, NULL);
+ return bgp_static_set_safi (AFI_IP6, SAFI_MPLS_VPN, vty, argv[idx_ipv6_prefix]->arg, argv[idx_ext_community]->arg, argv[idx_label]->arg, NULL, 0, NULL, NULL, NULL, NULL);
}
/* For testing purpose, static route of MPLS-VPN. */
DEFUN (no_vpnv6_network,
no_vpnv6_network_cmd,
- "no network X:X::X:X/M rd ASN:nn_or_IP-address:nn tag WORD",
+ "no network X:X::X:X/M rd ASN:nn_or_IP-address:nn <tag|label> (0-1048575)",
NO_STR
"Specify a network to announce via BGP\n"
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Specify Route Distinguisher\n"
"VPN Route Distinguisher\n"
- "BGP tag\n"
- "tag value\n")
+ "VPN NLRI label (tag)\n"
+ "VPN NLRI label (tag)\n"
+ "Label value\n")
{
int idx_ipv6_prefix = 2;
int idx_ext_community = 4;
- int idx_word = 6;
- return bgp_static_unset_safi (AFI_IP6, SAFI_MPLS_VPN, vty, argv[idx_ipv6_prefix]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, 0, NULL, NULL, NULL);
+ int idx_label = 6;
+ return bgp_static_unset_safi (AFI_IP6, SAFI_MPLS_VPN, vty, argv[idx_ipv6_prefix]->arg, argv[idx_ext_community]->arg, argv[idx_label]->arg, 0, NULL, NULL, NULL);
}
int
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index cb4d88859e..5c157b9539 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -4008,7 +4008,7 @@ bgp_static_update_safi (struct bgp *bgp, struct prefix *p,
if ((safi == SAFI_EVPN) || (safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
{
- if (bgp_static->igpnexthop.s_addr)
+ if (afi == AFI_IP)
{
bgp_attr_extra_get (&attr)->mp_nexthop_global_in = bgp_static->igpnexthop;
bgp_attr_extra_get (&attr)->mp_nexthop_len = IPV4_MAX_BYTELEN;
@@ -4454,7 +4454,7 @@ bgp_purge_static_redist_routes (struct bgp *bgp)
*/
int
bgp_static_set_safi (afi_t afi, safi_t safi, struct vty *vty, const char *ip_str,
- const char *rd_str, const char *tag_str,
+ const char *rd_str, const char *label_str,
const char *rmap_str, int evpn_type, const char *esi, const char *gwip,
const char *ethtag, const char *routermac)
{
@@ -4491,18 +4491,15 @@ bgp_static_set_safi (afi_t afi, safi_t safi, struct vty *vty, const char *ip_str
return CMD_WARNING;
}
- if (tag_str)
+ if (label_str)
{
- ret = str2tag (tag_str, tag);
- if (! ret)
- {
- vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ unsigned long label_val;
+ VTY_GET_INTEGER_RANGE("Label/tag", label_val, label_str, 0, 16777215);
+ encode_label (label_val, tag);
}
else
{
- encode_label (0, tag);
+ memset (tag, 0, sizeof(tag)); /* empty, not even BoS */
}
if (safi == SAFI_EVPN)
{
@@ -4562,8 +4559,8 @@ bgp_static_set_safi (afi_t afi, safi_t safi, struct vty *vty, const char *ip_str
if (rmap_str)
{
if (bgp_static->rmap.name)
- free (bgp_static->rmap.name);
- bgp_static->rmap.name = strdup (rmap_str);
+ XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name);
+ bgp_static->rmap.name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str);
bgp_static->rmap.map = route_map_lookup_by_name (rmap_str);
}
@@ -4594,7 +4591,7 @@ bgp_static_set_safi (afi_t afi, safi_t safi, struct vty *vty, const char *ip_str
/* Configure static BGP network. */
int
bgp_static_unset_safi(afi_t afi, safi_t safi, struct vty *vty, const char *ip_str,
- const char *rd_str, const char *tag_str,
+ const char *rd_str, const char *label_str,
int evpn_type, const char *esi, const char *gwip, const char *ethtag)
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
@@ -4628,11 +4625,15 @@ bgp_static_unset_safi(afi_t afi, safi_t safi, struct vty *vty, const char *ip_st
return CMD_WARNING;
}
- ret = str2tag (tag_str, tag);
- if (! ret)
+ if (label_str)
{
- vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
- return CMD_WARNING;
+ unsigned long label_val;
+ VTY_GET_INTEGER_RANGE("Label/tag", label_val, label_str, 0, MPLS_LABEL_MAX);
+ encode_label (label_val, tag);
+ }
+ else
+ {
+ memset (tag, 0, sizeof(tag)); /* empty, not even BoS */
}
prn = bgp_node_get (bgp->route[afi][safi],
@@ -10433,10 +10434,17 @@ bgp_config_write_network_vpn (struct vty *vty, struct bgp *bgp,
prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
label = decode_label (bgp_static->tag);
- vty_out (vty, " network %s/%d rd %s tag %d",
+ vty_out (vty, " network %s/%d rd %s label %d",
inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
p->prefixlen,
rdbuf, label);
+ if (bgp_static->rmap.name)
+ vty_out (vty, " route-map %s", bgp_static->rmap.name);
+ else
+ {
+ if (bgp_static->backdoor)
+ vty_out (vty, " backdoor");
+ }
vty_out (vty, "%s", VTY_NEWLINE);
}
return 0;
diff --git a/lib/privs.c b/lib/privs.c
index decd4bb7db..c25310c8d3 100644
--- a/lib/privs.c
+++ b/lib/privs.c
@@ -105,7 +105,7 @@ static struct
#ifdef HAVE_LCAPS /* Quagga -> Linux capabilities mappings */
[ZCAP_SETID] = { 2, (pvalue_t []) { CAP_SETGID,
CAP_SETUID }, },
- [ZCAP_BIND] = { 2, (pvalue_t []) { CAP_NET_BIND_SERVICE }, },
+ [ZCAP_BIND] = { 1, (pvalue_t []) { CAP_NET_BIND_SERVICE }, },
[ZCAP_NET_ADMIN] = { 1, (pvalue_t []) { CAP_NET_ADMIN }, },
[ZCAP_NET_RAW] = { 1, (pvalue_t []) { CAP_NET_RAW }, },
[ZCAP_CHROOT] = { 1, (pvalue_t []) { CAP_SYS_CHROOT, }, },
@@ -130,7 +130,7 @@ static struct
[ZCAP_CHROOT] = { 1, (pvalue_t []) { PRIV_PROC_CHROOT }, },
[ZCAP_NICE] = { 1, (pvalue_t []) { PRIV_PROC_PRIOCNTL }, },
[ZCAP_PTRACE] = { 1, (pvalue_t []) { PRIV_PROC_SESSION }, },
- [ZCAP_DAC_OVERRIDE] = { 2, (pvalue_t []) { PRIV_FILE_DAC_EXECUTE,
+ [ZCAP_DAC_OVERRIDE] = { 5, (pvalue_t []) { PRIV_FILE_DAC_EXECUTE,
PRIV_FILE_DAC_READ,
PRIV_FILE_DAC_SEARCH,
PRIV_FILE_DAC_WRITE,
diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c
index 6461963856..5dd10b4c72 100644
--- a/ospf6d/ospf6_intra.c
+++ b/ospf6d/ospf6_intra.c
@@ -1455,13 +1455,14 @@ ospf6_intra_route_calculation (struct ospf6_area *oa)
{
if (hook_add)
(*hook_add) (route);
+ route->flag = 0;
}
else
{
/* Redo the summaries as things might have changed */
ospf6_abr_originate_summary (route);
+ route->flag = 0;
}
- route->flag = 0;
}
if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c
index a54170e048..aa4909314a 100644
--- a/ospfd/ospf_abr.c
+++ b/ospfd/ospf_abr.c
@@ -197,9 +197,8 @@ ospf_area_range_set (struct ospf *ospf, struct in_addr area_id,
{
struct ospf_area *area;
struct ospf_area_range *range;
- int ret = OSPF_AREA_ID_FORMAT_ADDRESS;
- area = ospf_area_get (ospf, area_id, ret);
+ area = ospf_area_get (ospf, area_id);
if (area == NULL)
return 0;
@@ -233,9 +232,8 @@ ospf_area_range_cost_set (struct ospf *ospf, struct in_addr area_id,
{
struct ospf_area *area;
struct ospf_area_range *range;
- int ret = OSPF_AREA_ID_FORMAT_ADDRESS;
- area = ospf_area_get (ospf, area_id, ret);
+ area = ospf_area_get (ospf, area_id);
if (area == NULL)
return 0;
@@ -282,9 +280,8 @@ ospf_area_range_substitute_set (struct ospf *ospf, struct in_addr area_id,
{
struct ospf_area *area;
struct ospf_area_range *range;
- int ret = OSPF_AREA_ID_FORMAT_ADDRESS;
- area = ospf_area_get (ospf, area_id, ret);
+ area = ospf_area_get (ospf, area_id);
range = ospf_area_range_lookup (area, p);
if (range != NULL)
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index aeb12a59fa..137df16a05 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -795,7 +795,7 @@ ospf_vl_data_new (struct ospf_area *area, struct in_addr vl_peer)
vl_data->vl_peer.s_addr = vl_peer.s_addr;
vl_data->vl_area_id = area->area_id;
- vl_data->format = area->format;
+ vl_data->vl_area_id_fmt = area->area_id_fmt;
return vl_data;
}
@@ -869,7 +869,7 @@ ospf_vl_new (struct ospf *ospf, struct ospf_vl_data *vl_data)
zlog_debug ("ospf_vl_new(): set if->name to %s", vi->name);
area_id.s_addr = 0;
- area = ospf_area_get (ospf, area_id, OSPF_AREA_ID_FORMAT_ADDRESS);
+ area = ospf_area_get (ospf, area_id);
voi->area = area;
if (IS_DEBUG_OSPF_EVENT)
diff --git a/ospfd/ospf_interface.h b/ospfd/ospf_interface.h
index 39202f777a..c5e6594926 100644
--- a/ospfd/ospf_interface.h
+++ b/ospfd/ospf_interface.h
@@ -104,12 +104,12 @@ struct ospf_interface;
struct ospf_vl_data
{
- struct in_addr vl_peer; /* Router-ID of the peer for VLs. */
- struct in_addr vl_area_id; /* Transit area for this VL. */
- int format; /* area ID format */
- struct ospf_interface *vl_oi; /* Interface data structure for the VL. */
- struct vertex_nexthop nexthop; /* Nexthop router and oi to use */
- struct in_addr peer_addr; /* Address used to reach the peer. */
+ struct in_addr vl_peer; /* Router-ID of the peer */
+ struct in_addr vl_area_id; /* Transit area */
+ int vl_area_id_fmt; /* Area ID format */
+ struct ospf_interface *vl_oi; /* Interface data structure */
+ struct vertex_nexthop nexthop; /* Nexthop router and oi to use */
+ struct in_addr peer_addr; /* Address used to reach the peer */
u_char flags;
};
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index f409aa8bb4..caf1b0c668 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -67,36 +67,29 @@ static const char *ospf_network_type_str[] =
/* Utility functions. */
int
-ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
+str2area_id (const char *str, struct in_addr *area_id, int *area_id_fmt)
{
- char *endptr = NULL;
- unsigned long ret;
+ char *ep;
- /* match "A.B.C.D". */
- if (strchr (str, '.') != NULL)
- {
- ret = inet_aton (str, area_id);
- if (!ret)
- return -1;
- *format = OSPF_AREA_ID_FORMAT_ADDRESS;
- }
- /* match "<0-4294967295>". */
- else
- {
- if (*str == '-')
- return -1;
- errno = 0;
- ret = strtoul (str, &endptr, 10);
- if (*endptr != '\0' || errno || ret > UINT32_MAX)
- return -1;
+ area_id->s_addr = htonl (strtoul (str, &ep, 10));
+ if (*ep && !inet_aton (str, area_id))
+ return -1;
- area_id->s_addr = htonl (ret);
- *format = OSPF_AREA_ID_FORMAT_DECIMAL;
- }
+ *area_id_fmt = *ep ? OSPF_AREA_ID_FMT_DOTTEDQUAD : OSPF_AREA_ID_FMT_DECIMAL;
return 0;
}
+void
+area_id2str (char *buf, int length, struct in_addr *area_id, int area_id_fmt)
+{
+ memset (buf, 0, length);
+
+ if (area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD)
+ strncpy (buf, inet_ntoa (*area_id), length);
+ else
+ sprintf (buf, "%lu", (unsigned long) ntohl (area_id->s_addr));
+}
static int
str2metric (const char *str, int *metric)
@@ -534,7 +527,7 @@ DEFUN (ospf_network_area,
VTY_GET_IPV4_PREFIX ("network prefix", p, argv[idx_ipv4_prefixlen]->arg);
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
- ret = ospf_network_set (ospf, &p, area_id);
+ ret = ospf_network_set (ospf, &p, area_id, format);
if (ret == 0)
{
vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
@@ -641,6 +634,7 @@ DEFUN (ospf_area_range_cost,
VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg);
ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
+ ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format);
VTY_GET_INTEGER ("range cost", cost, argv[idx_cost]->arg);
ospf_area_range_cost_set (ospf, area_id, &p, cost);
@@ -669,6 +663,7 @@ DEFUN (ospf_area_range_not_advertise,
VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg);
ospf_area_range_set (ospf, area_id, &p, 0);
+ ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format);
return CMD_SUCCESS;
}
@@ -728,6 +723,7 @@ DEFUN (ospf_area_range_substitute,
VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[idx_ipv4_prefixlen_2]->arg);
ospf_area_range_substitute_set (ospf, area_id, &p, &s);
+ ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format);
return CMD_SUCCESS;
}
@@ -782,7 +778,7 @@ DEFUN (no_ospf_area_range_substitute,
struct ospf_vl_config_data {
struct vty *vty; /* vty stuff */
struct in_addr area_id; /* area ID from command line */
- int format; /* command line area ID format */
+ int area_id_fmt; /* command line area ID format */
struct in_addr vl_peer; /* command line vl_peer */
int auth_type; /* Authehntication type, if given */
char *auth_key; /* simple password if present */
@@ -821,11 +817,12 @@ ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
VTY_NEWLINE);
return NULL;
}
- area = ospf_area_get (ospf, area_id, vl_config->format);
+ area = ospf_area_get (ospf, area_id);
+ ospf_area_display_format_set (ospf, area, vl_config->area_id_fmt);
if (area->external_routing != OSPF_AREA_DEFAULT)
{
- if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
+ if (vl_config->area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD)
vty_out (vty, "Area %s is %s%s",
inet_ntoa (area_id),
area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
@@ -1037,7 +1034,8 @@ DEFUN (ospf_area_vlink,
ospf_vl_config_data_init(&vl_config, vty);
/* Read off first 2 parameters and check them */
- ret = ospf_str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &vl_config.format);
+ ret = str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id,
+ &vl_config.area_id_fmt);
if (ret < 0)
{
vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
@@ -1155,7 +1153,7 @@ DEFUN (ospf_area_vlink_intervals,
char *area_id = argv[1]->arg;
char *router_id = argv[3]->arg;
- ret = ospf_str2area_id (area_id, &vl_config.area_id, &vl_config.format);
+ ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt);
if (ret < 0)
{
vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
@@ -1210,7 +1208,7 @@ DEFUN (no_ospf_area_vlink,
ospf_vl_config_data_init(&vl_config, vty);
- ret = ospf_str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &format);
+ ret = str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &format);
if (ret < 0)
{
vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
@@ -1319,7 +1317,7 @@ DEFUN (no_ospf_area_vlink_intervals,
char *area_id = argv[2]->arg;
char *router_id = argv[4]->arg;
- ret = ospf_str2area_id (area_id, &vl_config.area_id, &vl_config.format);
+ ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt);
if (ret < 0)
{
vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
@@ -1371,7 +1369,8 @@ DEFUN (ospf_area_shortcut,
VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[idx_ipv4_number]->arg);
- area = ospf_area_get (ospf, area_id, format);
+ area = ospf_area_get (ospf, area_id);
+ ospf_area_display_format_set (ospf, area, format);
if (strncmp (argv[idx_enable_disable]->arg, "de", 2) == 0)
mode = OSPF_SHORTCUT_DEFAULT;
@@ -1437,6 +1436,7 @@ DEFUN (ospf_area_stub,
VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg);
ret = ospf_area_stub_set (ospf, area_id);
+ ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format);
if (ret == 0)
{
vty_out (vty, "First deconfigure all virtual link through this area%s",
@@ -1466,6 +1466,7 @@ DEFUN (ospf_area_stub_no_summary,
VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg);
ret = ospf_area_stub_set (ospf, area_id);
+ ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format);
if (ret == 0)
{
vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
@@ -1532,6 +1533,7 @@ ospf_area_nssa_cmd_handler (struct vty *vty, int argc, struct cmd_token **argv,
VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[1]->arg);
ret = ospf_area_nssa_set (ospf, area_id);
+ ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format);
if (ret == 0)
{
vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
@@ -1669,7 +1671,8 @@ DEFUN (ospf_area_default_cost,
VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[idx_ipv4_number]->arg);
VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[idx_number]->arg, 0, 16777215);
- area = ospf_area_get (ospf, area_id, format);
+ area = ospf_area_get (ospf, area_id);
+ ospf_area_display_format_set (ospf, area, format);
if (area->external_routing == OSPF_AREA_DEFAULT)
{
@@ -1756,7 +1759,8 @@ DEFUN (ospf_area_export_list,
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
- area = ospf_area_get (ospf, area_id, format);
+ area = ospf_area_get (ospf, area_id);
+ ospf_area_display_format_set (ospf, area, format);
ospf_area_export_list_set (ospf, area, argv[3]->arg);
return CMD_SUCCESS;
@@ -1807,7 +1811,8 @@ DEFUN (ospf_area_import_list,
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
- area = ospf_area_get (ospf, area_id, format);
+ area = ospf_area_get (ospf, area_id);
+ ospf_area_display_format_set (ospf, area, format);
ospf_area_import_list_set (ospf, area, argv[3]->arg);
return CMD_SUCCESS;
@@ -1863,7 +1868,8 @@ DEFUN (ospf_area_filter_list,
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
- area = ospf_area_get (ospf, area_id, format);
+ area = ospf_area_get (ospf, area_id);
+ ospf_area_display_format_set (ospf, area, format);
plist = prefix_list_lookup (AFI_IP, argv[idx_word]->arg);
if (strncmp (argv[idx_in_out]->arg, "in", 2) == 0)
{
@@ -1963,7 +1969,8 @@ DEFUN (ospf_area_authentication_message_digest,
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
- area = ospf_area_get (ospf, area_id, format);
+ area = ospf_area_get (ospf, area_id);
+ ospf_area_display_format_set (ospf, area, format);
area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
return CMD_SUCCESS;
@@ -1985,7 +1992,8 @@ DEFUN (ospf_area_authentication,
VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg);
- area = ospf_area_get (ospf, area_id, format);
+ area = ospf_area_get (ospf, area_id);
+ ospf_area_display_format_set (ospf, area, format);
area->auth_type = OSPF_AUTH_SIMPLE;
return CMD_SUCCESS;
@@ -7003,7 +7011,7 @@ DEFUN (ip_ospf_area,
return CMD_SUCCESS;
}
- ret = ospf_str2area_id (areaid, &area_id, &format);
+ ret = str2area_id (areaid, &area_id, &format);
if (ret < 0)
{
vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>%s",
@@ -8165,19 +8173,6 @@ const char *ospf_shortcut_mode_str[] =
"disable"
};
-
-static void
-area_id2str (char *buf, int length, struct ospf_area *area)
-{
- memset (buf, 0, length);
-
- if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
- strncpy (buf, inet_ntoa (area->area_id), length);
- else
- sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
-}
-
-
const char *ospf_int_type_str[] =
{
"unknown", /* should never be used. */
@@ -8424,7 +8419,7 @@ config_write_network_area (struct vty *vty, struct ospf *ospf)
memset (buf, 0, INET_ADDRSTRLEN);
/* Create Area ID string by specified Area ID format. */
- if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
+ if (n->area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD)
strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
else
sprintf ((char *) buf, "%lu",
@@ -8451,7 +8446,8 @@ config_write_ospf_area (struct vty *vty, struct ospf *ospf)
{
struct route_node *rn1;
- area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
+ area_id2str ((char *) buf, INET_ADDRSTRLEN, &area->area_id,
+ area->area_id_fmt);
if (area->auth_type != OSPF_AUTH_NULL)
{
@@ -8570,7 +8566,7 @@ config_write_virtual_link (struct vty *vty, struct ospf *ospf)
{
struct listnode *node;
struct ospf_vl_data *vl_data;
- u_char buf[INET_ADDRSTRLEN];
+ char buf[INET_ADDRSTRLEN];
/* Virtual-Link print */
for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
@@ -8582,12 +8578,8 @@ config_write_virtual_link (struct vty *vty, struct ospf *ospf)
if (vl_data != NULL)
{
memset (buf, 0, INET_ADDRSTRLEN);
-
- if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
- strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
- else
- sprintf ((char *) buf, "%lu",
- (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
+
+ area_id2str (buf, sizeof(buf), &vl_data->vl_area_id, vl_data->vl_area_id_fmt);
oi = vl_data->vl_oi;
/* timers */
diff --git a/ospfd/ospf_vty.h b/ospfd/ospf_vty.h
index 429ac318f7..cf6b322ac7 100644
--- a/ospfd/ospf_vty.h
+++ b/ospfd/ospf_vty.h
@@ -26,7 +26,7 @@
#define VTY_GET_OSPF_AREA_ID(V,F,STR) \
{ \
int retv; \
- retv = ospf_str2area_id ((STR), &(V), &(F)); \
+ retv = str2area_id ((STR), &(V), &(F)); \
if (retv < 0) \
{ \
vty_out (vty, "%% Invalid OSPF area ID%s", VTY_NEWLINE); \
@@ -37,7 +37,7 @@
#define VTY_GET_OSPF_AREA_ID_NO_BB(NAME,V,F,STR) \
{ \
int retv; \
- retv = ospf_str2area_id ((STR), &(V), &(F)); \
+ retv = str2area_id ((STR), &(V), &(F)); \
if (retv < 0) \
{ \
vty_out (vty, "%% Invalid OSPF area ID%s", VTY_NEWLINE); \
@@ -54,6 +54,7 @@
extern void ospf_vty_init (void);
extern void ospf_vty_show_init (void);
extern void ospf_vty_clear_init (void);
-extern int ospf_str2area_id (const char *, struct in_addr *, int *);
+extern int str2area_id (const char *, struct in_addr *, int *);
+extern void area_id2str (char *, int, struct in_addr *, int);
#endif /* _QUAGGA_OSPF_VTY_H */
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index 30b1e9622f..af68d1d35f 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -717,6 +717,7 @@ ospf_area_new (struct ospf *ospf, struct in_addr area_id)
new->ospf = ospf;
new->area_id = area_id;
+ new->area_id_fmt = OSPF_AREA_ID_FMT_DOTTEDQUAD;
new->external_routing = OSPF_AREA_DEFAULT;
new->default_cost = 1;
@@ -809,7 +810,7 @@ ospf_area_check_free (struct ospf *ospf, struct in_addr area_id)
}
struct ospf_area *
-ospf_area_get (struct ospf *ospf, struct in_addr area_id, int format)
+ospf_area_get (struct ospf *ospf, struct in_addr area_id)
{
struct ospf_area *area;
@@ -817,7 +818,6 @@ ospf_area_get (struct ospf *ospf, struct in_addr area_id, int format)
if (!area)
{
area = ospf_area_new (ospf, area_id);
- area->format = format;
listnode_add_sort (ospf->areas, area);
ospf_check_abr_status (ospf);
if (ospf->stub_router_admin_set == OSPF_STUB_ROUTER_ADMINISTRATIVE_SET)
@@ -920,13 +920,13 @@ static void update_redistributed(struct ospf *ospf, int add_to_ospf)
/* Config network statement related functions. */
static struct ospf_network *
-ospf_network_new (struct in_addr area_id, int format)
+ospf_network_new (struct in_addr area_id)
{
struct ospf_network *new;
new = XCALLOC (MTYPE_OSPF_NETWORK, sizeof (struct ospf_network));
new->area_id = area_id;
- new->format = format;
+ new->area_id_fmt = OSPF_AREA_ID_FMT_DOTTEDQUAD;
return new;
}
@@ -941,12 +941,11 @@ ospf_network_free (struct ospf *ospf, struct ospf_network *network)
int
ospf_network_set (struct ospf *ospf, struct prefix_ipv4 *p,
- struct in_addr area_id)
+ struct in_addr area_id, int df)
{
struct ospf_network *network;
struct ospf_area *area;
struct route_node *rn;
- int ret = OSPF_AREA_ID_FORMAT_ADDRESS;
rn = route_node_get (ospf->networks, (struct prefix *)p);
if (rn->info)
@@ -956,8 +955,10 @@ ospf_network_set (struct ospf *ospf, struct prefix_ipv4 *p,
return 0;
}
- rn->info = network = ospf_network_new (area_id, ret);
- area = ospf_area_get (ospf, area_id, ret);
+ rn->info = network = ospf_network_new (area_id);
+ network->area_id_fmt = df;
+ area = ospf_area_get (ospf, area_id);
+ ospf_area_display_format_set (ospf, area, df);
/* Run network config now. */
ospf_network_run ((struct prefix *)p, area);
@@ -1037,7 +1038,6 @@ ospf_interface_set (struct interface *ifp, struct in_addr area_id)
struct ospf *ospf;
struct ospf_if_params *params;
struct ospf_interface *oi;
- int ret = OSPF_AREA_ID_FORMAT_ADDRESS;
if ((ospf = ospf_lookup ()) == NULL)
return 1; /* Ospf not ready yet */
@@ -1047,7 +1047,7 @@ ospf_interface_set (struct interface *ifp, struct in_addr area_id)
SET_IF_PARAM (params, if_area);
params->if_area = area_id;
- area = ospf_area_get (ospf, area_id, ret);
+ area = ospf_area_get (ospf, area_id);
for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, co))
{
@@ -1235,7 +1235,7 @@ ospf_if_update (struct ospf *ospf, struct interface *ifp)
if (rn->info != NULL)
{
network = (struct ospf_network *) rn->info;
- area = ospf_area_get (ospf, network->area_id, network->format);
+ area = ospf_area_get (ospf, network->area_id);
ospf_network_run_interface (&rn->p, area, ifp);
}
@@ -1369,12 +1369,19 @@ ospf_area_vlink_count (struct ospf *ospf, struct ospf_area *area)
}
int
+ospf_area_display_format_set (struct ospf *ospf, struct ospf_area *area, int df)
+{
+ area->area_id_fmt = df;
+
+ return 1;
+}
+
+int
ospf_area_stub_set (struct ospf *ospf, struct in_addr area_id)
{
struct ospf_area *area;
- int format = OSPF_AREA_ID_FORMAT_ADDRESS;
- area = ospf_area_get (ospf, area_id, format);
+ area = ospf_area_get (ospf, area_id);
if (ospf_area_vlink_count (ospf, area))
return 0;
@@ -1405,9 +1412,8 @@ int
ospf_area_no_summary_set (struct ospf *ospf, struct in_addr area_id)
{
struct ospf_area *area;
- int format = OSPF_AREA_ID_FORMAT_ADDRESS;
- area = ospf_area_get (ospf, area_id, format);
+ area = ospf_area_get (ospf, area_id);
area->no_summary = 1;
return 1;
@@ -1432,9 +1438,8 @@ int
ospf_area_nssa_set (struct ospf *ospf, struct in_addr area_id)
{
struct ospf_area *area;
- int format = OSPF_AREA_ID_FORMAT_ADDRESS;
- area = ospf_area_get (ospf, area_id, format);
+ area = ospf_area_get (ospf, area_id);
if (ospf_area_vlink_count (ospf, area))
return 0;
diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h
index 9198d5c620..787a77bf96 100644
--- a/ospfd/ospfd.h
+++ b/ospfd/ospfd.h
@@ -322,9 +322,9 @@ struct ospf_area
struct in_addr area_id;
/* Area ID format. */
- char format;
-#define OSPF_AREA_ID_FORMAT_ADDRESS 1
-#define OSPF_AREA_ID_FORMAT_DECIMAL 2
+ int area_id_fmt;
+#define OSPF_AREA_ID_FMT_DOTTEDQUAD 1
+#define OSPF_AREA_ID_FMT_DECIMAL 2
/* Address range. */
struct list *address_range;
@@ -431,7 +431,7 @@ struct ospf_network
{
/* Area ID. */
struct in_addr area_id;
- int format;
+ int area_id_fmt;
};
/* OSPF NBMA neighbor structure. */
@@ -525,9 +525,11 @@ extern struct ospf *ospf_get_instance (u_short);
extern void ospf_finish (struct ospf *);
extern void ospf_router_id_update (struct ospf *ospf);
extern int ospf_network_set (struct ospf *, struct prefix_ipv4 *,
- struct in_addr);
+ struct in_addr, int);
extern int ospf_network_unset (struct ospf *, struct prefix_ipv4 *,
struct in_addr);
+extern int ospf_area_display_format_set (struct ospf *, struct ospf_area *area,
+ int df);
extern int ospf_area_stub_set (struct ospf *, struct in_addr);
extern int ospf_area_stub_unset (struct ospf *, struct in_addr);
extern int ospf_area_no_summary_set (struct ospf *, struct in_addr);
@@ -566,7 +568,7 @@ extern struct ospf_nbr_nbma *ospf_nbr_nbma_lookup_next (struct ospf *,
int);
extern int ospf_oi_count (struct interface *);
-extern struct ospf_area *ospf_area_get (struct ospf *, struct in_addr, int);
+extern struct ospf_area *ospf_area_get (struct ospf *, struct in_addr);
extern void ospf_area_check_free (struct ospf *, struct in_addr);
extern struct ospf_area *ospf_area_lookup_by_area_id (struct ospf *,
struct in_addr);
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index 80decc34cd..eeb72236cf 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -6210,7 +6210,7 @@ DEFUN (show_ip_msdp_peer_detail,
if (uj)
argc--;
- if (argc == 4)
+ if (argc > 4)
ip_msdp_show_peers_detail(vty, argv[4]->arg, uj);
else
ip_msdp_show_peers(vty, uj);