FD.io VPP  v19.08.3-2-gbabecb413
Vector Packet Processing
mactime.c
Go to the documentation of this file.
1 /*
2  * mactime.c - time-based src mac address filtration
3  *
4  * Copyright (c) 2018 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include <vnet/vnet.h>
19 #include <vnet/plugin/plugin.h>
20 #include <mactime/mactime.h>
21 
22 #include <vlibapi/api.h>
23 #include <vlibmemory/api.h>
24 #include <vpp/app/version.h>
25 
26 /* define message IDs */
28 
29 /* define message structures */
30 #define vl_typedefs
32 #undef vl_typedefs
33 
34 /* define generated endian-swappers */
35 #define vl_endianfun
37 #undef vl_endianfun
38 
39 /* instantiate all the print functions we know about */
40 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
41 #define vl_printfun
43 #undef vl_printfun
44 
45 /* Get the API version number */
46 #define vl_api_version(n,v) static u32 api_version=(v);
48 #undef vl_api_version
49 
50 #define REPLY_MSG_ID_BASE mm->msg_id_base
52 
54 
55 /** \file time-base src-mac filter device-input feature arc implementation
56  */
57 
58 /* List of message types that this plugin understands */
59 
60 #define foreach_mactime_plugin_api_msg \
61 _(MACTIME_ENABLE_DISABLE, mactime_enable_disable) \
62 _(MACTIME_ADD_DEL_RANGE, mactime_add_del_range)
63 
64 static void
66 {
67  if (mm->feature_initialized == 0)
68  {
69  /* Create the lookup table */
70  clib_bihash_init_8_8 (&mm->lookup_table, "mactime lookup table",
75  mm->allow_counters.name = "allow";
76  mm->allow_counters.stat_segment_name = "/mactime/allow";
77  mm->drop_counters.name = "drop";
78  mm->drop_counters.stat_segment_name = "/mactime/drop";
79  mm->feature_initialized = 1;
80  }
81 }
82 
83 /** Action function shared between message handler and debug CLI
84 */
85 int
87  int enable_disable)
88 {
90  int rv = 0;
91 
92  feature_init (mm);
93 
94  /* Utterly wrong? */
96  sw_if_index))
97  return VNET_API_ERROR_INVALID_SW_IF_INDEX;
98 
99  /* Not a physical port? */
100  sw = vnet_get_sw_interface (mm->vnet_main, sw_if_index);
102  return VNET_API_ERROR_INVALID_SW_IF_INDEX;
103 
104  vnet_feature_enable_disable ("device-input", "mactime",
105  sw_if_index, enable_disable, 0, 0);
106  vnet_feature_enable_disable ("interface-output", "mactime-tx",
107  sw_if_index, enable_disable, 0, 0);
108  return rv;
109 }
110 
111 static clib_error_t *
113  unformat_input_t * input,
114  vlib_cli_command_t * cmd)
115 {
117  u32 sw_if_index = ~0;
118  int enable_disable = 1;
119 
120  int rv;
121 
123  {
124  if (unformat (input, "disable"))
125  enable_disable = 0;
126  else if (unformat (input, "%U", unformat_vnet_sw_interface,
127  mm->vnet_main, &sw_if_index))
128  ;
129  else if (unformat (input, "sw_if_index %d", &sw_if_index))
130  ;
131  else
132  break;
133  }
134 
135  if (sw_if_index == ~0)
136  return clib_error_return (0, "Please specify an interface...");
137 
138  rv = mactime_enable_disable (mm, sw_if_index, enable_disable);
139 
140  switch (rv)
141  {
142  case 0:
143  break;
144 
145  case VNET_API_ERROR_INVALID_SW_IF_INDEX:
146  return clib_error_return
147  (0, "Invalid interface, only works on physical ports");
148  break;
149 
150  default:
151  return clib_error_return (0, "mactime_enable_disable returned %d", rv);
152  }
153  return 0;
154 }
155 
156 /* *INDENT-OFF* */
157 VLIB_CLI_COMMAND (mactime_enable_disable_command, static) =
158 {
159  .path = "mactime enable-disable",
160  .short_help =
161  "mactime enable-disable <interface-name> [disable]",
163 };
164 /* *INDENT-ON* */
165 
166 
167 /** Enable / disable time-base src mac filtration on an interface
168  */
169 
172 {
173  vl_api_mactime_enable_disable_reply_t *rmp;
175  int rv;
176 
178 
179  rv = mactime_enable_disable (mm, ntohl (mp->sw_if_index),
180  (int) (mp->enable_disable));
182  REPLY_MACRO (VL_API_MACTIME_ENABLE_DISABLE_REPLY);
183 }
184 
185 /** Create a lookup table entry for the indicated mac address
186  */
187 void
189 {
191  api_main_t *am;
192  vl_shmem_hdr_t *shmem_hdr;
193  u8 *name;
195 
196  am = &api_main;
197  shmem_hdr = am->shmem_hdr;
198  mp = vl_msg_api_alloc_as_if_client (sizeof (*mp));
199  clib_memset (mp, 0, sizeof (*mp));
200  mp->_vl_msg_id = ntohs (VL_API_MACTIME_ADD_DEL_RANGE + mm->msg_id_base);
201  name = format (0, "mac-%U", format_mac_address, mac_address);
202 
203  memcpy (mp->device_name, name, vec_len (name));
204  memcpy (mp->mac_address, mac_address, sizeof (mp->mac_address));
205  /* $$$ config: create allow / drop / range */
206  mp->allow = 1;
207  mp->is_add = 1;
208  vl_msg_api_send_shmem (shmem_hdr->vl_input_queue, (u8 *) & mp);
209 }
210 
211 /** Add or delete static / dynamic accept/drop configuration for a src mac
212  */
213 
216 {
218  vl_api_mactime_add_del_range_reply_t *rmp;
219  mactime_device_t *dp;
221  int found = 1;
222  clib_bihash_8_8_t *lut = &mm->lookup_table;
223  u64 data_quota;
224  int i, rv = 0;
225 
226  feature_init (mm);
227 
228  data_quota = clib_net_to_host_u64 (mp->data_quota);
229 
230  clib_memset (&kv, 0, sizeof (kv));
231  memcpy (&kv.key, mp->mac_address, sizeof (mp->mac_address));
232 
233  /* See if we have a lookup table entry for this src mac address */
234  if (clib_bihash_search_8_8 (lut, &kv, &kv) < 0)
235  found = 0;
236 
237  /* Add an entry? */
238  if (mp->is_add)
239  {
240  /* Create the device entry? */
241  if (found == 0)
242  {
243  pool_get (mm->devices, dp);
244  clib_memset (dp, 0, sizeof (*dp));
246  dp - mm->devices);
249  dp - mm->devices);
251  mp->device_name[ARRAY_LEN (mp->device_name) - 1] = 0;
252  dp->device_name = format (0, "%s%c", mp->device_name, 0);
253  memcpy (dp->mac_address, mp->mac_address, sizeof (mp->mac_address));
254  for (i = 0; i < clib_net_to_host_u32 (mp->count); i++)
255  {
256  clib_timebase_range_t _r, *r = &_r;
257  r->start = mp->ranges[i].start;
258  r->end = mp->ranges[i].end;
259  vec_add1 (dp->ranges, r[0]);
260  }
261  /* If we found some time ranges */
262  if (i)
263  {
264  /* Set allow/drop based on msg flags */
265  if (mp->drop)
267  if (mp->allow)
269  if (mp->allow_quota)
271  }
272  else
273  {
274  /* no ranges, it's a static allow/drop */
275  if (mp->drop)
277  if (mp->allow)
279  }
280  if (mp->no_udp_10001)
282 
283  dp->data_quota = data_quota;
284 
285  /* Add the hash table entry */
286  kv.value = dp - mm->devices;
287  clib_bihash_add_del_8_8 (lut, &kv, 1 /* is_add */ );
288  }
289  else /* add more ranges, flags, etc. */
290  {
291  dp = pool_elt_at_index (mm->devices, kv.value);
292 
293  for (i = 0; i < clib_net_to_host_u32 (mp->count); i++)
294  {
295  clib_timebase_range_t _r, *r = &_r;
296  r->start = mp->ranges[i].start;
297  r->end = mp->ranges[i].end;
298  vec_add1 (dp->ranges, r[0]);
299  }
300 
301  if (vec_len (dp->ranges))
302  {
303  /* Set allow/drop based on msg flags */
304  if (mp->drop)
306  if (mp->allow)
308  if (mp->allow_quota)
310  }
311  else
312  {
313  /* no ranges, it's a static allow/drop */
314  if (mp->drop)
316  if (mp->allow)
318  }
319  if (mp->no_udp_10001)
321 
322  dp->data_quota = data_quota;
323  }
324  }
325  else /* delete case */
326  {
327  if (found == 0)
328  {
329  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
330  goto reply;
331  }
332 
333  /* find the device entry */
334  dp = pool_elt_at_index (mm->devices, kv.value);
335 
336  /* Remove it from the lookup table */
337  clib_bihash_add_del_8_8 (lut, &kv, 0 /* is_add */ );
338  vec_free (dp->ranges);
339  pool_put (mm->devices, dp);
340  }
341 
342 reply:
343  REPLY_MACRO (VL_API_MACTIME_ADD_DEL_RANGE_REPLY);
344 }
345 
346 /* Set up the API message handling tables */
347 static clib_error_t *
349 {
351 #define _(N,n) \
352  vl_msg_api_set_handlers((VL_API_##N + mm->msg_id_base), \
353  #n, \
354  vl_api_##n##_t_handler, \
355  vl_noop_handler, \
356  vl_api_##n##_t_endian, \
357  vl_api_##n##_t_print, \
358  sizeof(vl_api_##n##_t), 1);
360 #undef _
361 
362  return 0;
363 }
364 
365 #define vl_msg_name_crc_list
367 #undef vl_msg_name_crc_list
368 
369 static void
371 {
372 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + mm->msg_id_base);
373  foreach_vl_msg_name_crc_mactime;
374 #undef _
375 }
376 
377 static clib_error_t *
379 {
381  clib_error_t *error = 0;
382  u8 *name;
383 
384  mm->vlib_main = vm;
385  mm->vnet_main = vnet_get_main ();
386 
387  name = format (0, "mactime_%08x%c", api_version, 0);
388 
389  /* Ask for a correctly-sized block of API message decode slots */
391  ((char *) name, VL_MSG_FIRST_AVAILABLE);
392 
393  error = mactime_plugin_api_hookup (vm);
394 
395  /* Add our API messages to the global name_crc hash table */
397 
398  vec_free (name);
399 
402  mm->timezone_offset = -5; /* US EST / EDT */
403  return error;
404 }
405 
407 
408 static clib_error_t *
410 {
412 
414  {
415  if (unformat (input, "lookup-table-buckets %u",
417  ;
418  else if (unformat (input, "lookup-table-memory %U",
420  ;
421  else if (unformat (input, "timezone_offset %d", &mm->timezone_offset))
422  ;
423  else
424  {
425  return clib_error_return (0, "unknown input '%U'",
426  format_unformat_error, input);
427  }
428  }
429  return 0;
430 }
431 
433 
434 /* *INDENT-OFF* */
435 VNET_FEATURE_INIT (mactime, static) =
436 {
437  .arc_name = "device-input",
438  .node_name = "mactime",
439  .runs_before = VNET_FEATURES ("ethernet-input"),
440 };
441 /* *INDENT-ON */
442 
443 /* *INDENT-OFF* */
444 VNET_FEATURE_INIT (mactime_tx, static) =
445 {
446  .arc_name = "interface-output",
447  .node_name = "mactime-tx",
448  .runs_before = VNET_FEATURES ("interface-tx"),
449 };
450 /* *INDENT-ON */
451 
452 /* *INDENT-OFF* */
454 {
455  .version = VPP_BUILD_VER,
456  .description = "Time-based MAC Source Address Filter",
457 };
458 /* *INDENT-ON* */
459 
460 u8 *
461 format_bytes_with_width (u8 * s, va_list * va)
462 {
463  uword nbytes = va_arg (*va, u64);
464  int width = va_arg (*va, int);
465  f64 nbytes_f64;
466  u8 *fmt;
467  char *suffix = "";
468 
469  if (width > 0)
470  fmt = format (0, "%%%d.3f%%s%c", width, 0);
471  else
472  fmt = format (0, "%%.3f%%s%c", 0);
473 
474  if (nbytes > (1024ULL * 1024ULL * 1024ULL))
475  {
476  nbytes_f64 = ((f64) nbytes) / (1024.0 * 1024.0 * 1024.0);
477  suffix = "G";
478  }
479  else if (nbytes > (1024ULL * 1024ULL))
480  {
481  nbytes_f64 = ((f64) nbytes) / (1024.0 * 1024.0);
482  suffix = "M";
483  }
484  else if (nbytes > 1024ULL)
485  {
486  nbytes_f64 = ((f64) nbytes) / (1024.0);
487  suffix = "K";
488  }
489  else
490  {
491  nbytes_f64 = (f64) nbytes;
492  suffix = "B";
493  }
494 
495  s = format (s, (char *) fmt, nbytes_f64, suffix);
496  vec_free (fmt);
497  return s;
498 }
499 
500 static clib_error_t *
502  unformat_input_t * input, vlib_cli_command_t * cmd)
503 {
505  mactime_device_t *dp;
506  u8 *macstring = 0;
507  char *status_string;
508  u32 *pool_indices = 0;
509  int verbose = 0;
510  int current_status = 99;
511  int i, j;
512  f64 now;
513  vlib_counter_t allow, drop;
514  ethernet_arp_ip4_entry_t *n, *pool;
515 
516  if (mm->feature_initialized == 0)
517  return clib_error_return
518  (0,
519  "Feature not initialized, suggest 'help mactime enable-disable'...");
520 
522  pool = ip4_neighbors_pool ();
523 
524  /* *INDENT-OFF* */
525  pool_foreach (n, pool,
526  ({
527  vec_add1 (mm->arp_cache_copy, n[0]);
528  }));
529  /* *INDENT-ON* */
530 
531  now = clib_timebase_now (&mm->timebase);
532 
533  if (PREDICT_FALSE ((now - mm->sunday_midnight) > 86400.0 * 7.0))
535 
536  if (unformat (input, "verbose %d", &verbose))
537  ;
538 
539  if (unformat (input, "verbose"))
540  verbose = 1;
541 
542  if (verbose)
543  vlib_cli_output (vm, "Time now: %U", format_clib_timebase_time, now);
544 
545  /* *INDENT-OFF* */
546  pool_foreach (dp, mm->devices,
547  ({
548  vec_add1 (pool_indices, dp - mm->devices);
549  }));
550  /* *INDENT-ON* */
551 
552  vlib_cli_output (vm, "%-15s %18s %14s %10s %11s %13s",
553  "Device Name", "Addresses", "Status",
554  "AllowPkt", "AllowByte", "DropPkt");
555 
556  for (i = 0; i < vec_len (pool_indices); i++)
557  {
558  dp = pool_elt_at_index (mm->devices, pool_indices[i]);
559 
560  /* Check dynamic ranges */
561  for (j = 0; j < vec_len (dp->ranges); j++)
562  {
563  clib_timebase_range_t *r = dp->ranges + j;
564  f64 start0, end0;
565 
566  start0 = r->start + mm->sunday_midnight;
567  end0 = r->end + mm->sunday_midnight;
568  if (verbose > 1)
569  vlib_cli_output (vm, " Range %d: %U - %U", j,
572 
573  if (now >= start0 && now <= end0)
574  {
576  current_status = 3;
578  current_status = 5;
579  else
580  current_status = 2;
581  if (verbose)
582  {
583  vlib_cli_output (vm, " Time in range %d:", j);
584  vlib_cli_output (vm, " %U - %U",
587  }
588  goto print;
589  }
590  }
591  if (verbose && j)
592  vlib_cli_output (vm, " No range match.");
594  current_status = 0;
596  current_status = 1;
598  current_status = 2;
600  current_status = 3;
602  current_status = 4;
603 
604  print:
605  vec_reset_length (macstring);
606  macstring = format (0, "%U", format_mac_address, dp->mac_address);
607  switch (current_status)
608  {
609  case 0:
610  status_string = "static drop";
611  break;
612  case 1:
613  status_string = "static allow";
614  break;
615  case 2:
616  status_string = "dynamic drop";
617  break;
618  case 3:
619  status_string = "dynamic allow";
620  break;
621  case 4:
622  status_string = "d-quota inact";
623  break;
624  case 5:
625  status_string = "d-quota activ";
626  break;
627  default:
628  status_string = "code bug!";
629  break;
630  }
632  &allow);
633  vlib_get_combined_counter (&mm->drop_counters, dp - mm->devices, &drop);
634  vlib_cli_output (vm, "%-15s %18s %14s %10lld %U %13lld",
635  dp->device_name, macstring, status_string,
636  allow.packets, format_bytes_with_width, allow.bytes,
637  10, drop.packets);
638  if (dp->data_quota > 0)
639  vlib_cli_output (vm, "%-54s %s%U %s%U", " ", "Quota ",
641  "Use ", format_bytes_with_width,
642  dp->data_used_in_range, 8);
643  /* This is really only good for small N... */
644  for (j = 0; j < vec_len (mm->arp_cache_copy); j++)
645  {
646  n = mm->arp_cache_copy + j;
647  if (!memcmp (dp->mac_address, n->mac.bytes, sizeof (n->mac)))
648  {
649  vlib_cli_output (vm, "%17s%U", " ", format_ip4_address,
650  &n->ip4_address);
651  }
652  }
653  }
654  vec_free (macstring);
655  vec_free (pool_indices);
656 
657  return 0;
658 }
659 
660 /* *INDENT-OFF* */
661 VLIB_CLI_COMMAND (show_mactime_command, static) =
662 {
663  .path = "show mactime",
664  .short_help = "show mactime [verbose]",
665  .function = show_mactime_command_fn,
666 };
667 /* *INDENT-ON* */
668 
669 static clib_error_t *
671  unformat_input_t * input, vlib_cli_command_t * cmd)
672 {
674 
675  if (mm->feature_initialized == 0)
676  return clib_error_return
677  (0,
678  "Feature not initialized, suggest 'help mactime enable-disable'...");
679 
682  vlib_cli_output (vm, "Mactime counters cleared...");
683  return 0;
684 }
685 
686 /* *INDENT-OFF* */
687 VLIB_CLI_COMMAND (clear_mactime_command, static) =
688 {
689  .path = "clear mactime",
690  .short_help = "clear mactime counters",
691  .function = clear_mactime_command_fn,
692 };
693 /* *INDENT-ON* */
694 
695 
696 
697 /*
698  * fd.io coding-style-patch-verification: ON
699  *
700  * Local Variables:
701  * eval: (c-set-style "gnu")
702  * End:
703  */
configure per src-mac time ranges
Definition: mactime.api:70
static void vl_api_mactime_add_del_range_t_handler(vl_api_mactime_add_del_range_t *mp)
Add or delete static / dynamic accept/drop configuration for a src mac.
Definition: mactime.c:215
vlib_combined_counter_main_t drop_counters
Definition: mactime.h:81
u64 data_quota
max bytes this device
Definition: mactime.api:79
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
Definition: counter.c:108
#define MACTIME_DEVICE_FLAG_DYNAMIC_ALLOW_QUOTA
Definition: mactime.h:50
char * stat_segment_name
Name in stat segment directory.
Definition: counter.h:194
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
VNET_FEATURE_INIT(mactime, static)
vnet_interface_main_t interface_main
Definition: vnet.h:56
int mactime_enable_disable(mactime_main_t *mm, u32 sw_if_index, int enable_disable)
Action function shared between message handler and debug CLI.
Definition: mactime.c:86
u16 msg_id_base
Definition: mactime.h:65
static clib_error_t * clear_mactime_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: mactime.c:670
unsigned long u64
Definition: types.h:89
#define foreach_mactime_plugin_api_msg
Definition: mactime.c:60
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
clib_timebase_t timebase
Definition: mactime.h:68
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
Combined counter to hold both packets and byte differences.
Definition: counter_types.h:26
int i
f64 end
end of the time range
Definition: mactime.api:40
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
unformat_function_t unformat_vnet_sw_interface
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:236
#define MACTIME_DEVICE_FLAG_DYNAMIC_ALLOW
Definition: mactime.h:49
unsigned char u8
Definition: types.h:56
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
double f64
Definition: types.h:142
static clib_error_t * show_mactime_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: mactime.c:501
u32 count
number of time ranges to follow
Definition: mactime.api:82
format_function_t format_ip4_address
Definition: format.h:75
clib_timebase_range_t * ranges
Definition: mactime.h:42
void vlib_clear_combined_counters(vlib_combined_counter_main_t *cm)
Clear a collection of combined counters.
Definition: counter.c:61
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:493
vl_api_interface_index_t sw_if_index
Definition: gre.api:50
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:173
#define MACTIME_MEMORY_SIZE
Definition: mactime.h:102
static f64 clib_timebase_now(clib_timebase_t *tb)
Definition: time_range.h:92
#define clib_error_return(e, args...)
Definition: error.h:99
struct vl_shmem_hdr_ * shmem_hdr
Binary API shared-memory segment header pointer.
Definition: api_common.h:266
vlib_main_t * vlib_main
Definition: mactime.h:95
unsigned int u32
Definition: types.h:88
void vl_msg_api_send_shmem(svm_queue_t *q, u8 *elem)
format_function_t format_clib_timebase_time
Definition: time_range.h:74
VLIB_PLUGIN_REGISTER()
u8 no_udp_10001
drop udp to port 10001
Definition: mactime.api:78
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:514
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread counters.
Definition: counter.h:285
ethernet_arp_ip4_entry_t * arp_cache_copy
Definition: mactime.h:92
mactime_main_t mactime_main
Definition: mactime.c:53
counter_t packets
packet counter
Definition: counter_types.h:28
vlib_combined_counter_main_t allow_counters
Definition: mactime.h:80
u64 key
the key
Definition: bihash_8_8.h:35
ip4_address_t ip4_address
Definition: arp.h:27
mac_address_t mac
Definition: arp.h:29
struct _unformat_input_t unformat_input_t
u64 data_used_in_range
Definition: mactime.h:40
u32 lookup_table_num_buckets
Definition: mactime.h:84
ethernet_arp_ip4_entry_t * ip4_neighbors_pool(void)
Definition: arp.c:1779
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:286
#define PREDICT_FALSE(x)
Definition: clib.h:112
#define VLIB_CONFIG_FUNCTION(x, n,...)
Definition: init.h:182
#define REPLY_MACRO(t)
static clib_error_t * mactime_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: mactime.c:112
uword lookup_table_memory_size
Definition: mactime.h:85
u8 name[64]
Definition: memclnt.api:152
static clib_error_t * mactime_config(vlib_main_t *vm, unformat_input_t *input)
Definition: mactime.c:409
api to enable or disable the time-based src mac filter on an interface
Definition: mactime.api:25
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:203
static clib_error_t * mactime_init(vlib_main_t *vm)
Definition: mactime.c:378
u64 value
the value
Definition: bihash_8_8.h:36
#define BAD_SW_IF_INDEX_LABEL
#define MACTIME_DEVICE_FLAG_DROP_UDP_10001
Definition: mactime.h:51
#define UNFORMAT_END_OF_INPUT
Definition: format.h:145
u8 mac_address[6]
src mac address
Definition: mactime.api:80
static void vlib_get_combined_counter(const vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thr...
Definition: counter.h:259
vlib_main_t * vm
Definition: buffer.c:323
f64 sunday_midnight
Definition: mactime.h:71
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
f64 clib_timebase_find_sunday_midnight(f64 start_time)
Definition: time_range.c:213
static void setup_message_id_table(mactime_main_t *mm, api_main_t *am)
Definition: mactime.c:370
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:283
8 octet key, 8 octet key value pair
Definition: bihash_8_8.h:33
#define ARRAY_LEN(x)
Definition: clib.h:63
void clib_timebase_init(clib_timebase_t *tb, i32 timezone_offset_in_hours, clib_timebase_daylight_time_t daylight_type)
Definition: time_range.c:19
svm_queue_t * vl_input_queue
Definition: memory_shared.h:84
#define MACTIME_DEVICE_FLAG_STATIC_DROP
Always drop packets from this device.
Definition: mactime.h:46
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:161
mactime_device_t * devices
Definition: mactime.h:77
static clib_error_t * mactime_plugin_api_hookup(vlib_main_t *vm)
Definition: mactime.c:348
f64 start
start of the time range
Definition: mactime.api:39
clib_bihash_8_8_t lookup_table
Definition: mactime.h:74
vl_api_time_range_t ranges[count]
time ranges, in seconds since Sunday began
Definition: mactime.api:84
static void feature_init(mactime_main_t *mm)
Definition: mactime.c:65
u8 mac_address[6]
#define VNET_FEATURES(...)
Definition: feature.h:442
void mactime_send_create_entry_message(u8 *mac_address)
Create a lookup table entry for the indicated mac address.
Definition: mactime.c:188
counter_t bytes
byte counter
Definition: counter_types.h:29
u32 sw_if_index
the interface handle
Definition: mactime.api:30
static void vl_api_mactime_enable_disable_t_handler(vl_api_mactime_enable_disable_t *mp)
Enable / disable time-base src mac filtration on an interface.
Definition: mactime.c:171
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u64 uword
Definition: types.h:112
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:837
char * name
The counter collection&#39;s name.
Definition: counter.h:193
#define MACTIME_DEVICE_FLAG_STATIC_ALLOW
Definition: mactime.h:47
int feature_initialized
Definition: mactime.h:89
u8 * format_bytes_with_width(u8 *s, va_list *va)
Definition: mactime.c:461
u8 * format_mac_address(u8 *s, va_list *args)
Definition: format.c:58
unformat_function_t unformat_memory_size
Definition: format.h:296
u8 * device_name
Definition: mactime.h:37
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
vnet_sw_interface_type_t type
Definition: interface.h:701
vnet_main_t * vnet_main
Definition: mactime.h:96
#define MACTIME_DEVICE_FLAG_DYNAMIC_DROP
Definition: mactime.h:48
u8 enable_disable
enable=1, disable=0
Definition: mactime.api:29
void * vl_msg_api_alloc_as_if_client(int nbytes)
#define MACTIME_NUM_BUCKETS
Definition: mactime.h:101
u8 device_name[64]
device name
Definition: mactime.api:81
u8 mac_address[6]
Definition: mactime.h:38
api_main_t api_main
Definition: api_shared.c:35
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:772
u8 allow_quota
allow subject to quota
Definition: mactime.api:77
i32 timezone_offset
Definition: mactime.h:86
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
Definition: feature.c:275
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:171
#define VALIDATE_SW_IF_INDEX(mp)
Definition: arp.h:24
u16 vl_msg_api_get_msg_ids(const char *name, int n)
Definition: api_shared.c:957