summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2019-10-30 01:53:25 +0000
committerFlorin Coras <florin.coras@gmail.com>2019-11-12 23:52:36 +0000
commit44d06916b9654f393176e9fa85d0442184decbea (patch)
treeb388fda47c121f5e9c194448641a80b90e9ae6c2
parent867b9ec6abed648ad95e263b65eb1dd60835c17d (diff)
tap: Move client registration check to top
Type: fix Change-Id: I33dc4cf7b6c69f74c7bf4971ce59442678b878ef Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
-rw-r--r--src/vnet/devices/tap/tapv2.api2
-rw-r--r--src/vnet/devices/tap/tapv2_api.c21
2 files changed, 14 insertions, 9 deletions
diff --git a/src/vnet/devices/tap/tapv2.api b/src/vnet/devices/tap/tapv2.api
index dee73043c0f..c11a07cf72a 100644
--- a/src/vnet/devices/tap/tapv2.api
+++ b/src/vnet/devices/tap/tapv2.api
@@ -55,7 +55,7 @@ define tap_create_v2
{
u32 client_index;
u32 context;
- u32 id;
+ u32 id [default= 0xffffffff] ;
u8 use_random_mac;
u8 mac_address[6];
u16 tx_ring_sz; /* optional, default is 256 entries, must be power of 2 */
diff --git a/src/vnet/devices/tap/tapv2_api.c b/src/vnet/devices/tap/tapv2_api.c
index 2471d0084e1..a1acacf4719 100644
--- a/src/vnet/devices/tap/tapv2_api.c
+++ b/src/vnet/devices/tap/tapv2_api.c
@@ -52,10 +52,15 @@ _(SW_INTERFACE_TAP_V2_DUMP, sw_interface_tap_v2_dump)
static void
vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
{
+ vl_api_registration_t *reg;
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
vnet_main_t *vnm = vnet_get_main ();
vlib_main_t *vm = vlib_get_main ();
vl_api_tap_create_v2_reply_t *rmp;
- vl_api_registration_t *reg;
+
tap_create_if_args_t _a, *ap = &_a;
clib_memset (ap, 0, sizeof (*ap));
@@ -119,9 +124,6 @@ vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
tap_create_if (vm, ap);
- reg = vl_api_client_index_to_registration (mp->client_index);
- if (!reg)
- return;;
/* If a tag was supplied... */
if (mp->tag[0])
@@ -145,18 +147,21 @@ vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp)
static void
vl_api_tap_delete_v2_t_handler (vl_api_tap_delete_v2_t * mp)
{
+ vl_api_registration_t *reg;
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
vnet_main_t *vnm = vnet_get_main ();
vlib_main_t *vm = vlib_get_main ();
int rv;
vl_api_tap_delete_v2_reply_t *rmp;
- vl_api_registration_t *reg;
+
u32 sw_if_index = ntohl (mp->sw_if_index);
rv = tap_delete_if (vm, sw_if_index);
- reg = vl_api_client_index_to_registration (mp->client_index);
- if (!reg)
- return;
+
rmp = vl_msg_api_alloc (sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_TAP_DELETE_V2_REPLY);
bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright (c) 2017-2019 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

#ifndef SRC_VNET_SESSION_MMA_TEMPLATE_H_
#define SRC_VNET_SESSION_MMA_TEMPLATE_H_

#include <vppinfra/pool.h>

#ifndef MMA_RT_TYPE
#error MMA_RT_TYPE not defined
#endif

#define _rt(a,b) a##_##b
#define __rt(a, b) _rt(a,b)
#define RT(a) __rt(a, MMA_RT_TYPE)

#define _rtt(a,b) a##_##b##_t
#define __rtt(a, b) _rtt(a,b)
#define RTT(a) __rtt(a, MMA_RT_TYPE)

#define MMA_TABLE_INVALID_INDEX ((u32)~0)

typedef struct
{
  u64 as_u64[MMA_RT_TYPE / 8];
} RTT (mma_mask_or_match);

typedef struct
{
  u32 action_index;
  u32 *next_indices;
  /* *INDENT-OFF* */
  RTT (mma_mask_or_match) mask;
  RTT (mma_mask_or_match) match;
  RTT (mma_mask_or_match) max_match;
  /* *INDENT-ON* */
} RTT (mma_rule);

typedef int (*RTT (rule_cmp_fn)) (RTT (mma_rule) * rule1,
				  RTT (mma_rule) * rule2);
typedef struct
{
  /** Root for rules tree */
  u32 root_index;

  /** Rules pool */
    RTT (mma_rule) * rules;

    RTT (rule_cmp_fn) rule_cmp_fn;
} RTT (mma_rules_table);

u32
RT (mma_table_lookup) (RTT (mma_rules_table) * srt,
		       RTT (mma_mask_or_match) * key, u32 rule_index);
u32
RT (mma_table_lookup_rule) (RTT (mma_rules_table) * srt,
			    RTT (mma_mask_or_match) * key, u32 rule_index);
int
RT (mma_table_add_rule) (RTT (mma_rules_table) * srt, RTT (mma_rule) * rule);
int
RT (mma_table_del_rule) (RTT (mma_rules_table) * srt,
			 RTT (mma_rule) * rule, u32 rule_index);
RTT (mma_rule) *
RT (mma_rules_table_rule_alloc) (RTT (mma_rules_table) * srt);
RTT (mma_rule) *
RT (session_rule_free) (RTT (mma_rules_table) * srt, RTT (mma_rule) * rule);
RTT (mma_rule) *
RT (mma_table_get_rule) (RTT (mma_rules_table) * srt, u32 srt_index);
u32
RT (mma_rules_table_rule_index) (RTT (mma_rules_table) * srt,
				 RTT (mma_rule) * sr);
#endif /* SRC_VNET_SESSION_MMA_TEMPLATE_H_ */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */