summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorvivek <vivek@cumulusnetworks.com>2016-08-10 00:55:51 +0200
committerPhilippe Guibert <philippe.guibert@6wind.com>2017-02-14 13:58:58 +0100
commit78b81eaa44d74c988a681b96574a7b6897e7dea0 (patch)
tree797b8d3d0ad309c04379118527e1e427d6c4d9ea /lib
parentlib: Functions related to AF_ETHERNET (diff)
downloadfrr-78b81eaa44d74c988a681b96574a7b6897e7dea0.tar.xz
frr-78b81eaa44d74c988a681b96574a7b6897e7dea0.zip
lib: Enhance prefix dump for EVPN prefixes
This commit is also taking into account changes related to srcdes feature introduction in zebra folder. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com> Ticket: CM-12262 Reviewed By: CCR-5065 Testing Done: Manual Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/prefix.c42
-rw-r--r--lib/prefix.h9
-rw-r--r--lib/srcdest_table.c4
-rw-r--r--lib/srcdest_table.h4
4 files changed, 39 insertions, 20 deletions
diff --git a/lib/prefix.c b/lib/prefix.c
index 06ed00baa..6d3de3d6c 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -859,23 +859,39 @@ str2prefix (const char *str, struct prefix *p)
}
const char *
-prefix2str (union prefix46constptr pu, char *str, int size)
+prefix2str (union prefixconstptr pu, char *str, int size)
{
const struct prefix *p = pu.p;
+ char buf[PREFIX2STR_BUFFER];
- if (p->family == AF_ETHERNET)
- {
- snprintf(str, size, "%02x:%02x:%02x:%02x:%02x:%02x/%d",
- p->u.prefix_eth.octet[0], p->u.prefix_eth.octet[1],
- p->u.prefix_eth.octet[2], p->u.prefix_eth.octet[3],
- p->u.prefix_eth.octet[4], p->u.prefix_eth.octet[5],
- p->prefixlen);
- }
- else
+ switch (p->family)
{
- char buf[PREFIX2STR_BUFFER];
- inet_ntop(p->family, &p->u.prefix, buf, sizeof(buf));
- snprintf(str, size, "%s/%d", buf, p->prefixlen);
+ u_char family;
+
+ case AF_INET:
+ case AF_INET6:
+ snprintf (str, size, "%s/%d",
+ inet_ntop (p->family, &p->u.prefix, buf, PREFIX2STR_BUFFER),
+ p->prefixlen);
+ break;
+
+ case AF_ETHERNET:
+ if (p->u.prefix_evpn.route_type == 5)
+ {
+ family = (p->u.prefix_evpn.flags & (IP_ADDR_V4 | IP_PREFIX_V4)) ?
+ AF_INET : AF_INET6;
+ snprintf (str, size, "[%d]:[%u][%s]/%d",
+ p->u.prefix_evpn.route_type,
+ p->u.prefix_evpn.eth_tag,
+ inet_ntop (family, &p->u.prefix_evpn.ip.addr,
+ buf, PREFIX2STR_BUFFER),
+ p->prefixlen);
+ }
+ break;
+
+ default:
+ sprintf (str, "UNK prefix");
+ break;
}
return str;
diff --git a/lib/prefix.h b/lib/prefix.h
index 1756dd21c..5c1c71a7c 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -69,6 +69,7 @@ struct evpn_addr
u_char ip_prefix_length;
union
{
+ u_char addr;
struct in_addr v4_addr;
struct in6_addr v6_addr;
} ip;
@@ -185,18 +186,20 @@ struct prefix_sg
* side, which strips type safety since the cast will accept any pointer
* type.)
*/
-union prefix46ptr
+union prefixptr
{
struct prefix *p;
struct prefix_ipv4 *p4;
struct prefix_ipv6 *p6;
+ struct prefix_evpn *evp;
} __attribute__ ((transparent_union));
-union prefix46constptr
+union prefixconstptr
{
const struct prefix *p;
const struct prefix_ipv4 *p4;
const struct prefix_ipv6 *p6;
+ const struct prefix_evpn *evp;
} __attribute__ ((transparent_union));
#ifndef INET_ADDRSTRLEN
@@ -270,7 +273,7 @@ extern int str2prefix (const char *, struct prefix *);
#define PREFIX2STR_BUFFER PREFIX_STRLEN
-extern const char *prefix2str (union prefix46constptr, char *, int);
+extern const char *prefix2str (union prefixconstptr, char *, int);
extern int prefix_match (const struct prefix *, const struct prefix *);
extern int prefix_same (const struct prefix *, const struct prefix *);
extern int prefix_cmp (const struct prefix *, const struct prefix *);
diff --git a/lib/srcdest_table.c b/lib/srcdest_table.c
index dd148fa41..04c9eff79 100644
--- a/lib/srcdest_table.c
+++ b/lib/srcdest_table.c
@@ -242,7 +242,7 @@ srcdest_route_next(struct route_node *rn)
}
struct route_node *
-srcdest_rnode_get (struct route_table *table, union prefix46ptr dst_pu,
+srcdest_rnode_get (struct route_table *table, union prefixptr dst_pu,
struct prefix_ipv6 *src_p)
{
struct prefix_ipv6 *dst_p = dst_pu.p6;
@@ -253,7 +253,7 @@ srcdest_rnode_get (struct route_table *table, union prefix46ptr dst_pu,
}
struct route_node *
-srcdest_rnode_lookup (struct route_table *table, union prefix46ptr dst_pu,
+srcdest_rnode_lookup (struct route_table *table, union prefixptr dst_pu,
struct prefix_ipv6 *src_p)
{
struct prefix_ipv6 *dst_p = dst_pu.p6;
diff --git a/lib/srcdest_table.h b/lib/srcdest_table.h
index 59111b5d1..207f5d121 100644
--- a/lib/srcdest_table.h
+++ b/lib/srcdest_table.h
@@ -57,10 +57,10 @@ extern route_table_delegate_t _srcdest_srcnode_delegate;
extern struct route_table *srcdest_table_init(void);
extern struct route_node *srcdest_rnode_get(struct route_table *table,
- union prefix46ptr dst_pu,
+ union prefixptr dst_pu,
struct prefix_ipv6 *src_p);
extern struct route_node *srcdest_rnode_lookup(struct route_table *table,
- union prefix46ptr dst_pu,
+ union prefixptr dst_pu,
struct prefix_ipv6 *src_p);
extern void srcdest_rnode_prefixes (struct route_node *rn, struct prefix **p,
struct prefix **src_p);