summaryrefslogtreecommitdiffstats
path: root/src/plugins/acl/dataplane_node.c
diff options
context:
space:
mode:
authorAndrew Yourtchenko <ayourtch@gmail.com>2018-10-24 20:51:30 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2018-10-24 21:21:19 +0200
commita6386d4ec41ed1ba14007a2e1a006f2d1533e0e0 (patch)
treeb05d919e6b0753a15eec0ad5a0eaf13fb797b8fc /src/plugins/acl/dataplane_node.c
parenta0f0c964049d16155a49ef4cf986a16c34acfaec (diff)
acl-plugin: introduce a format function for l4 session key
Abstracting out the internal format function for L4 session key type makes the other acl plugin format/print functions more maintainable. Change-Id: Ica1302263a42981555462b5338d18d9a9f9c8342 Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Diffstat (limited to 'src/plugins/acl/dataplane_node.c')
-rw-r--r--src/plugins/acl/dataplane_node.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/plugins/acl/dataplane_node.c b/src/plugins/acl/dataplane_node.c
index fef355138e0..53176fdd2c5 100644
--- a/src/plugins/acl/dataplane_node.c
+++ b/src/plugins/acl/dataplane_node.c
@@ -630,31 +630,38 @@ static u8 *
format_fa_5tuple (u8 * s, va_list * args)
{
fa_5tuple_t *p5t = va_arg (*args, fa_5tuple_t *);
+ void *paddr0;
+ void *paddr1;
+ void *format_address_func;
+ void *ip_af;
+ void *ip_frag_txt =
+ p5t->pkt.is_nonfirst_fragment ? " non-initial fragment" : "";
if (p5t->pkt.is_ip6)
- return format (s, "lc_index %d (lsb16 of sw_if_index %d) l3 %s%s %U -> %U"
- " l4 proto %d l4_valid %d port %d -> %d tcp flags (%s) %02x rsvd %x",
- p5t->pkt.lc_index, p5t->l4.lsb_of_sw_if_index,
- "ip6",
- p5t->
- pkt.is_nonfirst_fragment ? " non-initial fragment" : "",
- format_ip6_address, &p5t->ip6_addr[0], format_ip6_address,
- &p5t->ip6_addr[1], p5t->l4.proto, p5t->pkt.l4_valid,
- p5t->l4.port[0], p5t->l4.port[1],
- p5t->pkt.tcp_flags_valid ? "valid" : "invalid",
- p5t->pkt.tcp_flags, p5t->pkt.flags_reserved);
+ {
+ ip_af = "ip6";
+ format_address_func = format_ip6_address;
+ paddr0 = &p5t->ip6_addr[0];
+ paddr1 = &p5t->ip6_addr[1];
+ }
else
- return format (s, "lc_index %d (lsb16 of sw_if_index %d) l3 %s%s %U -> %U"
- " l4 proto %d l4_valid %d port %d -> %d tcp flags (%s) %02x rsvd %x",
- p5t->pkt.lc_index, p5t->l4.lsb_of_sw_if_index,
- "ip4",
- p5t->
- pkt.is_nonfirst_fragment ? " non-initial fragment" : "",
- format_ip4_address, &p5t->ip4_addr[0], format_ip4_address,
- &p5t->ip4_addr[1], p5t->l4.proto, p5t->pkt.l4_valid,
- p5t->l4.port[0], p5t->l4.port[1],
- p5t->pkt.tcp_flags_valid ? "valid" : "invalid",
- p5t->pkt.tcp_flags, p5t->pkt.flags_reserved);
+ {
+ ip_af = "ip4";
+ format_address_func = format_ip4_address;
+ paddr0 = &p5t->ip4_addr[0];
+ paddr1 = &p5t->ip4_addr[1];
+ }
+
+ s =
+ format (s, "lc_index %d l3 %s%s ", p5t->pkt.lc_index, ip_af, ip_frag_txt);
+ s =
+ format (s, "%U -> %U ", format_address_func, paddr0, format_address_func,
+ paddr1);
+ s = format (s, "%U ", format_fa_session_l4_key, &p5t->l4);
+ s = format (s, "tcp flags (%s) %02x rsvd %x",
+ p5t->pkt.tcp_flags_valid ? "valid" : "invalid",
+ p5t->pkt.tcp_flags, p5t->pkt.flags_reserved);
+ return s;
}
#ifndef CLIB_MARCH_VARIANT