diff options
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/ip/punt.c | 43 | ||||
-rw-r--r-- | src/vnet/ip/punt.h | 42 | ||||
-rw-r--r-- | src/vnet/ipsec/ipsec_punt.c | 10 | ||||
-rw-r--r-- | src/vnet/ipsec/ipsec_punt.h | 10 | ||||
-rw-r--r-- | src/vnet/vxlan-gbp/vxlan_gbp.c | 17 |
5 files changed, 101 insertions, 21 deletions
diff --git a/src/vnet/ip/punt.c b/src/vnet/ip/punt.c index 7cdb5fcc084..6fb8dd58776 100644 --- a/src/vnet/ip/punt.c +++ b/src/vnet/ip/punt.c @@ -405,6 +405,32 @@ punt_l4_add_del (vlib_main_t * vm, } } +/** + * @brief Request exception traffic punt. + * + * @param reason Punting reason + * + * @returns 0 on success, non-zero value otherwise + */ +static clib_error_t * +punt_exception_add_del (vlib_punt_reason_t reason, bool is_add) +{ + punt_main_t *pm = &punt_main; + int rv = 0; + vnet_punt_reason_flag_t flag = vlib_punt_reason_get_flags (reason); + const char *node_name = + vnet_punt_reason_flag_is_IP6_PACKET (flag) ? "ip6-punt" : "ip4-punt"; + if (is_add) + rv = vlib_punt_register (pm->hdl, reason, node_name); + else + rv = vlib_punt_unregister (pm->hdl, reason, node_name); + if (!rv) + return 0; + else + return clib_error_return (0, is_add ? "Existing punting registration..." : + "Punting registration not found..."); +} + clib_error_t * vnet_punt_add_del (vlib_main_t * vm, const punt_reg_t * pr, bool is_add) { @@ -414,6 +440,7 @@ vnet_punt_add_del (vlib_main_t * vm, const punt_reg_t * pr, bool is_add) return (punt_l4_add_del (vm, pr->punt.l4.af, pr->punt.l4.protocol, pr->punt.l4.port, is_add)); case PUNT_TYPE_EXCEPTION: + return punt_exception_add_del (pr->punt.exception.reason, is_add); case PUNT_TYPE_IP_PROTO: break; } @@ -449,6 +476,9 @@ punt_cli (vlib_main_t * vm, { if (unformat (input, "del")) is_add = false; + else if (unformat (input, "reason %U", unformat_punt_reason, + &pr.punt.exception.reason)) + pr.type = PUNT_TYPE_EXCEPTION; else if (unformat (input, "ipv4")) pr.punt.l4.af = AF_IP4; else if (unformat (input, "ipv6")) @@ -809,6 +839,19 @@ ip_punt_init (vlib_main_t * vm) return (error); } +u8 * +format_vnet_punt_reason_flags (u8 *s, va_list *args) +{ + vnet_punt_reason_flag_t flag = va_arg (*args, int); +#define _(pos, len, value, name, str) \ + if (vnet_punt_reason_flag_is_##name (flag)) \ + s = format (s, "%s ", str); + + foreach_vnet_punt_reason_flag +#undef _ + return (s); +} + VLIB_INIT_FUNCTION (ip_punt_init); static clib_error_t * diff --git a/src/vnet/ip/punt.h b/src/vnet/ip/punt.h index 33124846ba6..858ea531ef7 100644 --- a/src/vnet/ip/punt.h +++ b/src/vnet/ip/punt.h @@ -24,17 +24,49 @@ #include <stdbool.h> #include <vnet/ip/ip.h> +/* Punting reason flags bitfield + * (position, length, value, name, string) + */ +#define foreach_vnet_punt_reason_flag \ + _ (0, 1, 0, IP4_PACKET, "ip4-packet") \ + _ (0, 1, 1, IP6_PACKET, "ip6-packet") + +typedef enum vnet_punt_reason_flag_t_ +{ +#define _(pos, len, value, name, str) \ + VNET_PUNT_REASON_F_##name = ((value) << (pos)), + foreach_vnet_punt_reason_flag +#undef _ +} __clib_packed vnet_punt_reason_flag_t; + +enum vnet_punt_reason_flag_mask_t_ +{ +#define _(pos, len, value, name, str) \ + VNET_PUNT_REASON_F_MASK_##name = (((1 << (len)) - 1) << (pos)), + foreach_vnet_punt_reason_flag +#undef _ +}; + +/* predicates associated with vlib_punt_reason_flag_t*/ +#define _(pos, len, value, name, str) \ + static_always_inline int vnet_punt_reason_flag_is_##name ( \ + vnet_punt_reason_flag_t f) \ + { \ + return (f & VNET_PUNT_REASON_F_MASK_##name) == VNET_PUNT_REASON_F_##name; \ + } +foreach_vnet_punt_reason_flag +#undef _ + #define foreach_punt_type \ _(L4, "l4") \ _(EXCEPTION, "exception") \ _(IP_PROTO, "ip-proto") -typedef enum punt_type_t_ -{ + typedef enum punt_type_t_ { #define _(v, s) PUNT_TYPE_##v, - foreach_punt_type + foreach_punt_type #undef _ -} punt_type_t; + } punt_type_t; typedef struct punt_l4_t_ { @@ -138,6 +170,8 @@ typedef walk_rc_t (*punt_client_walk_cb_t) (const punt_client_t * pc, extern void punt_client_walk (punt_type_t pt, punt_client_walk_cb_t cb, void *ctx); +extern u8 *format_vnet_punt_reason_flags (u8 *s, va_list *args); + /* * inlines for the data-plane */ diff --git a/src/vnet/ipsec/ipsec_punt.c b/src/vnet/ipsec/ipsec_punt.c index a08231ab299..8a276546a56 100644 --- a/src/vnet/ipsec/ipsec_punt.c +++ b/src/vnet/ipsec/ipsec_punt.c @@ -18,6 +18,7 @@ #include <vnet/ipsec/ipsec.h> #include <vnet/ipsec/ipsec_punt.h> #include <vnet/ipsec/ipsec_tun.h> +#include <vnet/ip/punt.h> static vlib_punt_hdl_t punt_hdl; @@ -48,10 +49,11 @@ ipsec_punt_init (vlib_main_t * vm) punt_hdl = vlib_punt_client_register ("ipsec"); -#define _(s,v) vlib_punt_reason_alloc (punt_hdl, v, \ - ipsec_punt_interested_listener, \ - NULL, \ - &ipsec_punt_reason[IPSEC_PUNT_##s]); +#define _(s, v, f) \ + vlib_punt_reason_alloc (punt_hdl, v, ipsec_punt_interested_listener, NULL, \ + &ipsec_punt_reason[IPSEC_PUNT_##s], \ + VNET_PUNT_REASON_F_##f, \ + format_vnet_punt_reason_flags); foreach_ipsec_punt_reason #undef _ return (error); diff --git a/src/vnet/ipsec/ipsec_punt.h b/src/vnet/ipsec/ipsec_punt.h index f95e1da9133..afed908bffb 100644 --- a/src/vnet/ipsec/ipsec_punt.h +++ b/src/vnet/ipsec/ipsec_punt.h @@ -17,14 +17,14 @@ #include <vlib/vlib.h> -#define foreach_ipsec_punt_reason \ - _(IP4_SPI_UDP_0, "ipsec4-spi-o-udp-0") \ - _(IP4_NO_SUCH_TUNNEL, "ipsec4-no-such-tunnel") \ - _(IP6_NO_SUCH_TUNNEL, "ipsec6-no-such-tunnel") +#define foreach_ipsec_punt_reason \ + _ (IP4_SPI_UDP_0, "ipsec4-spi-o-udp-0", IP4_PACKET) \ + _ (IP4_NO_SUCH_TUNNEL, "ipsec4-no-such-tunnel", IP4_PACKET) \ + _ (IP6_NO_SUCH_TUNNEL, "ipsec6-no-such-tunnel", IP6_PACKET) typedef enum ipsec_punt_reason_t_ { -#define _(s,v) IPSEC_PUNT_##s, +#define _(s, v, f) IPSEC_PUNT_##s, foreach_ipsec_punt_reason #undef _ IPSEC_PUNT_N_REASONS, diff --git a/src/vnet/vxlan-gbp/vxlan_gbp.c b/src/vnet/vxlan-gbp/vxlan_gbp.c index d1267cffc13..37cfd728121 100644 --- a/src/vnet/vxlan-gbp/vxlan_gbp.c +++ b/src/vnet/vxlan-gbp/vxlan_gbp.c @@ -14,6 +14,7 @@ */ #include <vnet/vxlan-gbp/vxlan_gbp.h> #include <vnet/ip/format.h> +#include <vnet/ip/punt.h> #include <vnet/fib/fib_entry.h> #include <vnet/fib/fib_table.h> #include <vnet/fib/fib_entry_track.h> @@ -1163,14 +1164,14 @@ vxlan_gbp_init (vlib_main_t * vm) punt_hdl = vlib_punt_client_register ("vxlan-gbp"); - vlib_punt_reason_alloc (punt_hdl, - "VXLAN-GBP-no-such-v4-tunnel", - NULL, NULL, - &vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP4]); - vlib_punt_reason_alloc (punt_hdl, - "VXLAN-GBP-no-such-v6-tunnel", - NULL, NULL, - &vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP6]); + vlib_punt_reason_alloc (punt_hdl, "VXLAN-GBP-no-such-v4-tunnel", NULL, NULL, + &vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP4], + VNET_PUNT_REASON_F_IP4_PACKET, + format_vnet_punt_reason_flags); + vlib_punt_reason_alloc (punt_hdl, "VXLAN-GBP-no-such-v6-tunnel", NULL, NULL, + &vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP6], + VNET_PUNT_REASON_F_IP6_PACKET, + format_vnet_punt_reason_flags); return (0); } |