From e14fda0fb4de174090a953e09fb677f1cfeddcbb Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 6 Jan 2017 12:24:03 -0500 Subject: [PATCH 1/2] bgpd: Allow 'neighbor X local-as Y' to have large values On ARM platforms specifying a local-as greater than 2 billion causes issues due to atoi usage. Ticket: CM-14019 Signed-off-by: Donald Sharp --- bgpd/bgp_vty.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 29649c5b24..b435543e39 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -3237,12 +3237,13 @@ DEFUN (neighbor_local_as, { struct peer *peer; int ret; - + as_t as; peer = peer_and_group_lookup_vty (vty, argv[0]); if (! peer) return CMD_WARNING; - ret = peer_local_as_set (peer, atoi (argv[1]), 0, 0); + VTY_GET_INTEGER_RANGE ("Local AS", as, argv[1], 1, BGP_AS4_MAX); + ret = peer_local_as_set (peer, as, 0, 0); return bgp_vty_return (vty, ret); } @@ -3257,12 +3258,14 @@ DEFUN (neighbor_local_as_no_prepend, { struct peer *peer; int ret; + as_t as; peer = peer_and_group_lookup_vty (vty, argv[0]); if (! peer) return CMD_WARNING; - ret = peer_local_as_set (peer, atoi (argv[1]), 1, 0); + VTY_GET_INTEGER_RANGE ("Local AS", as, argv[1], 1, BGP_AS4_MAX); + ret = peer_local_as_set (peer, as, 1, 0); return bgp_vty_return (vty, ret); } @@ -3278,12 +3281,14 @@ DEFUN (neighbor_local_as_no_prepend_replace_as, { struct peer *peer; int ret; + as_t as; peer = peer_and_group_lookup_vty (vty, argv[0]); if (! peer) return CMD_WARNING; - ret = peer_local_as_set (peer, atoi (argv[1]), 1, 1); + VTY_GET_INTEGER_RANGE ("Local AS", as, argv[1], 1, BGP_AS4_MAX); + ret = peer_local_as_set (peer, as, 1, 1); return bgp_vty_return (vty, ret); } From ec91182539f592ddd4d19228d728e5ec7623c196 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 6 Jan 2017 12:25:55 -0500 Subject: [PATCH 2/2] zebra: Allow tag values greater than 2 billion on arm Due to the usage of atol, values that are larger than 2 billion on arm for tag are not converted correctly. Ticket: CM-14099 Signed-off-by: Donald Sharp --- zebra/zebra_vty.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 98c20270c3..5088198624 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -104,7 +104,7 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd, /* tag */ if (tag_str) - tag = atol(tag_str); + VTY_GET_INTEGER_RANGE("tag", tag, tag_str, 0, 4294967295); /* VRF id */ zvrf = zebra_vrf_lookup_by_name (vrf_id_str); @@ -2707,11 +2707,11 @@ DEFUN (show_ip_route_tag, if (argc > 1) { - tag = atol(argv[1]); + VTY_GET_INTEGER_RANGE("tag", tag, argv[1], 0, 4294967295); VRF_GET_ID (vrf_id, argv[0]); } else - tag = atol(argv[0]); + VTY_GET_INTEGER_RANGE("tag", tag, argv[0], 0, 4294967295); table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); if (! table) @@ -3341,7 +3341,7 @@ DEFUN (show_ip_route_vrf_all_tag, route_tag_t tag = 0; if (argv[0]) - tag = atol(argv[0]); + VTY_GET_INTEGER_RANGE("tag", tag, argv[0], 0, 4294967295); RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { @@ -3777,7 +3777,7 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, /* tag */ if (tag_str) - tag = atol(tag_str); + VTY_GET_INTEGER_RANGE("tag", tag, tag_str, 0, 4294967295); /* When gateway is valid IPv6 addrees, then gate is treated as nexthop address other case gate is treated as interface name. */ @@ -5026,10 +5026,10 @@ DEFUN (show_ipv6_route_tag, if (argc > 1) { VRF_GET_ID (vrf_id, argv[0]); - tag = atol(argv[1]); + VTY_GET_INTEGER_RANGE("tag", tag, argv[1], 0, 4294967295); } else - tag = atol(argv[0]); + VTY_GET_INTEGER_RANGE("tag", tag, argv[0], 0, 4294967295); table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); if (! table) @@ -5469,7 +5469,7 @@ DEFUN (show_ipv6_route_vrf_all_tag, route_tag_t tag = 0; if (argv[0]) - tag = atol(argv[0]); + VTY_GET_INTEGER_RANGE("tag", tag, argv[0], 0, 4294967295); RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {