summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2016-05-24 23:19:11 +0200
committerDamjan Marion <damarion@cisco.com>2016-06-13 19:04:12 +0200
commit86be48773c1833129317a3a0d6fe8165eb69ac3f (patch)
treeff6ddc2933e9a18aba8e3e841fb6f495bc7efe4a
parenta38c3df5fd2bf1bf8b3389e882f6dcd5ac533202 (diff)
Explicity specify IP address type for format_ip46_address function
Change-Id: I3379517535a98a7a5fbd3173503f288a81378821 Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r--vnet/vnet/ethernet/arp.c4
-rw-r--r--vnet/vnet/ip/ip6_format.c18
-rw-r--r--vnet/vnet/ip/ip6_neighbor.c4
-rw-r--r--vnet/vnet/ip/lookup.c6
-rw-r--r--vnet/vnet/vxlan/vxlan.c4
-rw-r--r--vpp-api-test/vat/api_format.c20
-rw-r--r--vpp/api/custom_dump.c6
7 files changed, 50 insertions, 12 deletions
diff --git a/vnet/vnet/ethernet/arp.c b/vnet/vnet/ethernet/arp.c
index aa37f25fb2d..d9e4b9b2612 100644
--- a/vnet/vnet/ethernet/arp.c
+++ b/vnet/vnet/ethernet/arp.c
@@ -1314,7 +1314,7 @@ arp_add_del_adj_cb (struct ip_lookup_main_t * lm,
{
if (!e)
clib_warning("Adjacency contains unknown ARP next hop %U (del)",
- format_ip46_address, &adj->arp.next_hop);
+ format_ip46_address, &adj->arp.next_hop, IP46_TYPE_IP4);
else
arp_ip4_entry_del_adj(e, adj->heap_handle);
}
@@ -1322,7 +1322,7 @@ arp_add_del_adj_cb (struct ip_lookup_main_t * lm,
{
if (!e)
clib_warning("Adjacency contains unknown ARP next hop %U (add)",
- format_ip46_address, &adj->arp.next_hop);
+ format_ip46_address, &adj->arp.next_hop, IP46_TYPE_IP4);
else
arp_ip4_entry_add_adj(e, adj->heap_handle);
}
diff --git a/vnet/vnet/ip/ip6_format.c b/vnet/vnet/ip/ip6_format.c
index ad834f4db8a..5d32189478b 100644
--- a/vnet/vnet/ip/ip6_format.c
+++ b/vnet/vnet/ip/ip6_format.c
@@ -341,7 +341,23 @@ uword unformat_ip46_address (unformat_input_t * input, va_list * args)
u8 * format_ip46_address (u8 * s, va_list * args)
{
ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
- return ip46_address_is_ip4(ip46)?
+ ip46_type_t type = va_arg (*args, ip46_type_t);
+ int is_ip4 = 1;
+
+ switch (type)
+ {
+ case IP46_TYPE_ANY:
+ is_ip4 = ip46_address_is_ip4(ip46);
+ break;
+ case IP46_TYPE_IP4:
+ is_ip4 = 1;
+ break;
+ case IP46_TYPE_IP6:
+ is_ip4 = 0;
+ break;
+ }
+
+ return is_ip4 ?
format(s, "%U", format_ip4_address, &ip46->ip4):
format(s, "%U", format_ip6_address, &ip46->ip6);
}
diff --git a/vnet/vnet/ip/ip6_neighbor.c b/vnet/vnet/ip/ip6_neighbor.c
index 19eb5a8d54d..0dad232ce5d 100644
--- a/vnet/vnet/ip/ip6_neighbor.c
+++ b/vnet/vnet/ip/ip6_neighbor.c
@@ -3241,7 +3241,7 @@ ip6_neighbor_add_del_adj_cb (struct ip_lookup_main_t * lm,
{
if (!n)
clib_warning("Adjacency contains unknown ND next hop %U (del)",
- format_ip46_address, &adj->arp.next_hop);
+ format_ip46_address, &adj->arp.next_hop, IP46_TYPE_IP6);
else
ip6_neighbor_entry_del_adj(n, adj->heap_handle);
}
@@ -3249,7 +3249,7 @@ ip6_neighbor_add_del_adj_cb (struct ip_lookup_main_t * lm,
{
if (!n)
clib_warning("Adjacency contains unknown ND next hop %U (add)",
- format_ip46_address, &adj->arp.next_hop);
+ format_ip46_address, &adj->arp.next_hop, IP46_TYPE_IP6);
else
ip6_neighbor_entry_add_adj(n, adj->heap_handle);
}
diff --git a/vnet/vnet/ip/lookup.c b/vnet/vnet/ip/lookup.c
index 2f638f7799b..5a56870f9b2 100644
--- a/vnet/vnet/ip/lookup.c
+++ b/vnet/vnet/ip/lookup.c
@@ -1000,7 +1000,8 @@ u8 * format_ip_adjacency (u8 * s, va_list * args)
if (adj->if_address_index != ~0)
s = format (s, " %U", format_ip_interface_address, lm, adj->if_address_index);
if (adj->arp.next_hop.ip6.as_u64[0] || adj->arp.next_hop.ip6.as_u64[1])
- s = format (s, " via %U", format_ip46_address, &adj->arp.next_hop);
+ s = format (s, " via %U", format_ip46_address,
+ &adj->arp.next_hop, IP46_TYPE_ANY);
break;
case IP_LOOKUP_NEXT_LOCAL:
if (adj->if_address_index != ~0)
@@ -1011,7 +1012,8 @@ u8 * format_ip_adjacency (u8 * s, va_list * args)
s = format (s, " table %d", adj->classify.table_index);
case IP_LOOKUP_NEXT_INDIRECT:
- s = format (s, " via %U", format_ip46_address, &adj->indirect.next_hop);
+ s = format (s, " via %U", format_ip46_address,
+ &adj->indirect.next_hop, IP46_TYPE_ANY);
default:
break;
}
diff --git a/vnet/vnet/vxlan/vxlan.c b/vnet/vnet/vxlan/vxlan.c
index 133fc6f450c..86d49248e62 100644
--- a/vnet/vnet/vxlan/vxlan.c
+++ b/vnet/vnet/vxlan/vxlan.c
@@ -45,8 +45,8 @@ u8 * format_vxlan_tunnel (u8 * s, va_list * args)
s = format (s,
"[%d] %U (src) %U (dst) vni %d encap_fib_index %d",
t - ngm->tunnels,
- format_ip46_address, &t->src,
- format_ip46_address, &t->dst,
+ format_ip46_address, &t->src, IP46_TYPE_ANY,
+ format_ip46_address, &t->dst, IP46_TYPE_ANY,
t->vni,
t->encap_fib_index);
s = format (s, " decap_next %U\n", format_decap_next, t->decap_next_index);
diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c
index 666a4bd19c5..410bab50b31 100644
--- a/vpp-api-test/vat/api_format.c
+++ b/vpp-api-test/vat/api_format.c
@@ -474,7 +474,23 @@ u8 * format_ip6_address (u8 * s, va_list * args)
u8 * format_ip46_address (u8 * s, va_list * args)
{
ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
- return ip46_address_is_ip4(ip46)?
+ ip46_type_t type = va_arg (*args, ip46_type_t);
+ int is_ip4 = 1;
+
+ switch (type)
+ {
+ case IP46_TYPE_ANY:
+ is_ip4 = ip46_address_is_ip4(ip46);
+ break;
+ case IP46_TYPE_IP4:
+ is_ip4 = 1;
+ break;
+ case IP46_TYPE_IP6:
+ is_ip4 = 0;
+ break;
+ }
+
+ return is_ip4 ?
format(s, "%U", format_ip4_address, &ip46->ip4):
format(s, "%U", format_ip6_address, &ip46->ip6);
}
@@ -7522,7 +7538,9 @@ static void vl_api_vxlan_tunnel_details_t_handler
fformat(vam->ofp, "%11d%24U%24U%14d%18d%13d\n",
ntohl(mp->sw_if_index),
format_ip46_address, &(mp->src_address[0]),
+ IP46_TYPE_ANY,
format_ip46_address, &(mp->dst_address[0]),
+ IP46_TYPE_ANY,
ntohl(mp->encap_vrf_id),
ntohl(mp->decap_next_index),
ntohl(mp->vni));
diff --git a/vpp/api/custom_dump.c b/vpp/api/custom_dump.c
index 638c4a78b6e..f49e1b05cb2 100644
--- a/vpp/api/custom_dump.c
+++ b/vpp/api/custom_dump.c
@@ -1335,10 +1335,12 @@ static void * vl_api_vxlan_add_del_tunnel_t_print
s = format (0, "SCRIPT: vxlan_add_del_tunnel ");
s = format (s, "dst %U ", format_ip46_address,
- (ip46_address_t *)&(mp->dst_address));
+ (ip46_address_t *)&(mp->dst_address),
+ mp->is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4);
s = format (s, "src %U ", format_ip46_address,
- (ip46_address_t *)&(mp->src_address));
+ (ip46_address_t *)&(mp->src_address),
+ mp->is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4);
if (mp->encap_vrf_id)
s = format (s, "encap-vrf-id %d ", ntohl(mp->encap_vrf_id));