libnl  3.2.28
vlan.c
1 /*
2  * lib/route/link/vlan.c VLAN Link Info
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation version 2.1
7  * of the License.
8  *
9  * Copyright (c) 2003-2013 Thomas Graf <tgraf@suug.ch>
10  */
11 
12 /**
13  * @ingroup link
14  * @defgroup vlan VLAN
15  * Virtual LAN link module
16  *
17  * @details
18  * \b Link Type Name: "vlan"
19  *
20  * @route_doc{link_vlan, VLAN Documentation}
21  *
22  * @{
23  */
24 
25 #include <netlink-private/netlink.h>
26 #include <netlink/netlink.h>
27 #include <netlink/attr.h>
28 #include <netlink/utils.h>
29 #include <netlink/object.h>
30 #include <netlink/route/rtnl.h>
31 #include <netlink-private/route/link/api.h>
32 #include <netlink/route/link/vlan.h>
33 
34 #include <linux/if_vlan.h>
35 
36 /** @cond SKIP */
37 #define VLAN_HAS_ID (1<<0)
38 #define VLAN_HAS_FLAGS (1<<1)
39 #define VLAN_HAS_INGRESS_QOS (1<<2)
40 #define VLAN_HAS_EGRESS_QOS (1<<3)
41 #define VLAN_HAS_PROTOCOL (1<<4)
42 
43 struct vlan_info
44 {
45  uint16_t vi_vlan_id;
46  uint16_t vi_protocol;
47  unsigned int vi_ingress_qos_mask:(VLAN_PRIO_MAX+1);
48  uint32_t vi_flags;
49  uint32_t vi_flags_mask;
50  uint32_t vi_ingress_qos[VLAN_PRIO_MAX+1];
51  uint32_t vi_negress;
52  uint32_t vi_egress_size;
53  struct vlan_map * vi_egress_qos;
54  uint32_t vi_mask;
55 };
56 
57 /** @endcond */
58 
59 static struct nla_policy vlan_policy[IFLA_VLAN_MAX+1] = {
60  [IFLA_VLAN_ID] = { .type = NLA_U16 },
61  [IFLA_VLAN_FLAGS] = { .minlen = sizeof(struct ifla_vlan_flags) },
62  [IFLA_VLAN_INGRESS_QOS] = { .type = NLA_NESTED },
63  [IFLA_VLAN_EGRESS_QOS] = { .type = NLA_NESTED },
64  [IFLA_VLAN_PROTOCOL] = { .type = NLA_U16 },
65 };
66 
67 static int vlan_alloc(struct rtnl_link *link)
68 {
69  struct vlan_info *vi;
70 
71  if (link->l_info) {
72  vi = link->l_info;
73  free(vi->vi_egress_qos);
74  memset(link->l_info, 0, sizeof(*vi));
75  } else {
76  if ((vi = calloc(1, sizeof(*vi))) == NULL)
77  return -NLE_NOMEM;
78 
79  link->l_info = vi;
80  }
81 
82  return 0;
83 }
84 
85 static int vlan_parse(struct rtnl_link *link, struct nlattr *data,
86  struct nlattr *xstats)
87 {
88  struct nlattr *tb[IFLA_VLAN_MAX+1];
89  struct vlan_info *vi;
90  int err;
91 
92  NL_DBG(3, "Parsing VLAN link info\n");
93 
94  if ((err = nla_parse_nested(tb, IFLA_VLAN_MAX, data, vlan_policy)) < 0)
95  goto errout;
96 
97  if ((err = vlan_alloc(link)) < 0)
98  goto errout;
99 
100  vi = link->l_info;
101 
102  if (tb[IFLA_VLAN_ID]) {
103  vi->vi_vlan_id = nla_get_u16(tb[IFLA_VLAN_ID]);
104  vi->vi_mask |= VLAN_HAS_ID;
105  }
106 
107  if (tb[IFLA_VLAN_PROTOCOL]) {
108  vi->vi_protocol = nla_get_u16(tb[IFLA_VLAN_PROTOCOL]);
109  vi->vi_mask |= VLAN_HAS_PROTOCOL;
110  }
111 
112  if (tb[IFLA_VLAN_FLAGS]) {
113  struct ifla_vlan_flags flags;
114  nla_memcpy(&flags, tb[IFLA_VLAN_FLAGS], sizeof(flags));
115 
116  vi->vi_flags = flags.flags;
117  vi->vi_mask |= VLAN_HAS_FLAGS;
118  }
119 
120  if (tb[IFLA_VLAN_INGRESS_QOS]) {
121  struct ifla_vlan_qos_mapping *map;
122  struct nlattr *nla;
123  int remaining;
124 
125  vi->vi_ingress_qos_mask = 0;
126  memset(vi->vi_ingress_qos, 0, sizeof(vi->vi_ingress_qos));
127 
128  nla_for_each_nested(nla, tb[IFLA_VLAN_INGRESS_QOS], remaining) {
129  if (nla_len(nla) < sizeof(*map))
130  return -NLE_INVAL;
131 
132  map = nla_data(nla);
133  if (map->from > VLAN_PRIO_MAX) {
134  return -NLE_INVAL;
135  }
136 
137  /* Kernel will not explicitly serialize mappings with "to" zero
138  * (although they are implicitly set).
139  *
140  * Thus we only mark those as "set" which are explicitly sent.
141  * That is similar to what we do with the egress map and it preserves
142  * previous behavior before NL_CAPABILITY_RTNL_LINK_VLAN_INGRESS_MAP_CLEAR.
143  *
144  * It matters only when a received object is send back to kernel to modify
145  * the link.
146  */
147  vi->vi_ingress_qos_mask |= (1 << map->from);
148  vi->vi_ingress_qos[map->from] = map->to;
149  }
150 
151  vi->vi_mask |= VLAN_HAS_INGRESS_QOS;
152  }
153 
154  if (tb[IFLA_VLAN_EGRESS_QOS]) {
155  struct ifla_vlan_qos_mapping *map;
156  struct nlattr *nla;
157  int remaining, i = 0;
158 
159  nla_for_each_nested(nla, tb[IFLA_VLAN_EGRESS_QOS], remaining) {
160  if (nla_len(nla) < sizeof(*map))
161  return -NLE_INVAL;
162  i++;
163  }
164 
165  /* align to have a little reserve */
166  vi->vi_egress_size = (i + 32) & ~31;
167  vi->vi_egress_qos = calloc(vi->vi_egress_size, sizeof(*vi->vi_egress_qos));
168  if (vi->vi_egress_qos == NULL)
169  return -NLE_NOMEM;
170 
171  i = 0;
172  nla_for_each_nested(nla, tb[IFLA_VLAN_EGRESS_QOS], remaining) {
173  map = nla_data(nla);
174  NL_DBG(4, "Assigning egress qos mapping %d\n", i);
175  vi->vi_egress_qos[i].vm_from = map->from;
176  vi->vi_egress_qos[i++].vm_to = map->to;
177  }
178 
179  vi->vi_negress = i;
180  vi->vi_mask |= VLAN_HAS_EGRESS_QOS;
181  }
182 
183  err = 0;
184 errout:
185  return err;
186 }
187 
188 static void vlan_free(struct rtnl_link *link)
189 {
190  struct vlan_info *vi = link->l_info;
191 
192  if (vi) {
193  free(vi->vi_egress_qos);
194  vi->vi_egress_qos = NULL;
195  }
196 
197  free(vi);
198  link->l_info = NULL;
199 }
200 
201 static void vlan_dump_line(struct rtnl_link *link, struct nl_dump_params *p)
202 {
203  struct vlan_info *vi = link->l_info;
204 
205  nl_dump(p, "vlan-id %d", vi->vi_vlan_id);
206 }
207 
208 static void vlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p)
209 {
210  struct vlan_info *vi = link->l_info;
211  int printed;
212  uint32_t i;
213  char buf[64];
214 
215  rtnl_link_vlan_flags2str(vi->vi_flags, buf, sizeof(buf));
216  nl_dump_line(p, " vlan-info id %d <%s>", vi->vi_vlan_id, buf);
217 
218  if (vi->vi_mask & VLAN_HAS_PROTOCOL)
219  nl_dump_line(p, " vlan protocol <%d>", ntohs(vi->vi_protocol));
220 
221  nl_dump(p, "\n");
222 
223  if (vi->vi_mask & VLAN_HAS_INGRESS_QOS) {
224  nl_dump_line(p,
225  " ingress vlan prio -> qos/socket prio mapping:\n");
226  for (i = 0, printed = 0; i <= VLAN_PRIO_MAX; i++) {
227  if (vi->vi_ingress_qos_mask & (1 << i)) {
228  if (printed == 0)
229  nl_dump_line(p, " ");
230  nl_dump(p, "%x -> %#08x, ",
231  i, vi->vi_ingress_qos[i]);
232  if (printed++ == 3) {
233  nl_dump(p, "\n");
234  printed = 0;
235  }
236  }
237  }
238 
239  if (printed > 0 && printed != 4)
240  nl_dump(p, "\n");
241  }
242 
243  if (vi->vi_mask & VLAN_HAS_EGRESS_QOS) {
244  nl_dump_line(p,
245  " egress qos/socket prio -> vlan prio mapping:\n");
246  for (i = 0, printed = 0; i < vi->vi_negress; i++) {
247  if (printed == 0)
248  nl_dump_line(p, " ");
249  nl_dump(p, "%#08x -> %x, ",
250  vi->vi_egress_qos[i].vm_from,
251  vi->vi_egress_qos[i].vm_to);
252  if (printed++ == 3) {
253  nl_dump(p, "\n");
254  printed = 0;
255  }
256  }
257 
258  if (printed > 0 && printed != 4)
259  nl_dump(p, "\n");
260  }
261 }
262 
263 static int vlan_clone(struct rtnl_link *dst, struct rtnl_link *src)
264 {
265  struct vlan_info *vdst, *vsrc = src->l_info;
266  int err;
267 
268  dst->l_info = NULL;
269  if ((err = rtnl_link_set_type(dst, "vlan")) < 0)
270  return err;
271  vdst = dst->l_info;
272 
273  vdst->vi_egress_qos = calloc(vsrc->vi_egress_size,
274  sizeof(struct vlan_map));
275  if (!vdst->vi_egress_qos)
276  return -NLE_NOMEM;
277 
278  memcpy(vdst->vi_egress_qos, vsrc->vi_egress_qos,
279  vsrc->vi_egress_size * sizeof(struct vlan_map));
280 
281  return 0;
282 }
283 
284 static int vlan_put_attrs(struct nl_msg *msg, struct rtnl_link *link)
285 {
286  struct vlan_info *vi = link->l_info;
287  struct nlattr *data;
288 
289  if (!(data = nla_nest_start(msg, IFLA_INFO_DATA)))
290  return -NLE_MSGSIZE;
291 
292  if (vi->vi_mask & VLAN_HAS_ID)
293  NLA_PUT_U16(msg, IFLA_VLAN_ID, vi->vi_vlan_id);
294 
295  if (vi->vi_mask & VLAN_HAS_PROTOCOL)
296  NLA_PUT_U16(msg, IFLA_VLAN_PROTOCOL, vi->vi_protocol);
297 
298  if (vi->vi_mask & VLAN_HAS_FLAGS) {
299  struct ifla_vlan_flags flags = {
300  .flags = vi->vi_flags,
301  .mask = vi->vi_flags_mask,
302  };
303 
304  NLA_PUT(msg, IFLA_VLAN_FLAGS, sizeof(flags), &flags);
305  }
306 
307  if (vi->vi_mask & VLAN_HAS_INGRESS_QOS) {
308  struct ifla_vlan_qos_mapping map;
309  struct nlattr *qos;
310  int i;
311 
312  if (!(qos = nla_nest_start(msg, IFLA_VLAN_INGRESS_QOS)))
313  goto nla_put_failure;
314 
315  for (i = 0; i <= VLAN_PRIO_MAX; i++) {
316  if (vi->vi_ingress_qos_mask & (1 << i)) {
317  map.from = i;
318  map.to = vi->vi_ingress_qos[i];
319 
320  NLA_PUT(msg, i, sizeof(map), &map);
321  }
322  }
323 
324  nla_nest_end(msg, qos);
325  }
326 
327  if (vi->vi_mask & VLAN_HAS_EGRESS_QOS) {
328  struct ifla_vlan_qos_mapping map;
329  struct nlattr *qos;
330  uint32_t i;
331 
332  if (!(qos = nla_nest_start(msg, IFLA_VLAN_EGRESS_QOS)))
333  goto nla_put_failure;
334 
335  for (i = 0; i < vi->vi_negress; i++) {
336  map.from = vi->vi_egress_qos[i].vm_from;
337  map.to = vi->vi_egress_qos[i].vm_to;
338 
339  NLA_PUT(msg, i, sizeof(map), &map);
340  }
341 
342  nla_nest_end(msg, qos);
343  }
344 
345  nla_nest_end(msg, data);
346 
347 nla_put_failure:
348 
349  return 0;
350 }
351 
352 static struct rtnl_link_info_ops vlan_info_ops = {
353  .io_name = "vlan",
354  .io_alloc = vlan_alloc,
355  .io_parse = vlan_parse,
356  .io_dump = {
357  [NL_DUMP_LINE] = vlan_dump_line,
358  [NL_DUMP_DETAILS] = vlan_dump_details,
359  },
360  .io_clone = vlan_clone,
361  .io_put_attrs = vlan_put_attrs,
362  .io_free = vlan_free,
363 };
364 
365 /** @cond SKIP */
366 #define IS_VLAN_LINK_ASSERT(link) \
367  if ((link)->l_info_ops != &vlan_info_ops) { \
368  APPBUG("Link is not a vlan link. set type \"vlan\" first."); \
369  return -NLE_OPNOTSUPP; \
370  }
371 /** @endcond */
372 
373 /**
374  * @name VLAN Object
375  * @{
376  */
377 
378 /**
379  * Allocate link object of type VLAN
380  *
381  * @return Allocated link object or NULL.
382  */
384 {
385  struct rtnl_link *link;
386  int err;
387 
388  if (!(link = rtnl_link_alloc()))
389  return NULL;
390 
391  if ((err = rtnl_link_set_type(link, "vlan")) < 0) {
392  rtnl_link_put(link);
393  return NULL;
394  }
395 
396  return link;
397 }
398 
399 /**
400  * Check if link is a VLAN link
401  * @arg link Link object
402  *
403  * @return True if link is a VLAN link, otherwise false is returned.
404  */
405 int rtnl_link_is_vlan(struct rtnl_link *link)
406 {
407  return link->l_info_ops && !strcmp(link->l_info_ops->io_name, "vlan");
408 }
409 
410 /**
411  * Set VLAN ID
412  * @arg link Link object
413  * @arg id VLAN identifier
414  *
415  * @return 0 on success or a negative error code
416  */
417 int rtnl_link_vlan_set_id(struct rtnl_link *link, uint16_t id)
418 {
419  struct vlan_info *vi = link->l_info;
420 
421  IS_VLAN_LINK_ASSERT(link);
422 
423  vi->vi_vlan_id = id;
424  vi->vi_mask |= VLAN_HAS_ID;
425 
426  return 0;
427 }
428 
429 /**
430  * Get VLAN Id
431  * @arg link Link object
432  *
433  * @return VLAN id, 0 if not set or a negative error code.
434  */
436 {
437  struct vlan_info *vi = link->l_info;
438 
439  IS_VLAN_LINK_ASSERT(link);
440 
441  if (vi->vi_mask & VLAN_HAS_ID)
442  return vi->vi_vlan_id;
443  else
444  return 0;
445 }
446 
447 /**
448  * Set VLAN protocol
449  * @arg link Link object
450  * @arg protocol VLAN protocol in network byte order.
451  * Probably you want to set it to something like htons(ETH_P_8021Q).
452  *
453  * @return 0 on success or a negative error code
454  */
455 int rtnl_link_vlan_set_protocol(struct rtnl_link *link, uint16_t protocol)
456 {
457  struct vlan_info *vi = link->l_info;
458 
459  IS_VLAN_LINK_ASSERT(link);
460 
461  vi->vi_protocol = protocol;
462  vi->vi_mask |= VLAN_HAS_PROTOCOL;
463 
464  return 0;
465 }
466 
467 /**
468  * Get VLAN protocol
469  * @arg link Link object
470  *
471  * @return VLAN protocol in network byte order like htons(ETH_P_8021Q),
472  * 0 if not set or a negative error code.
473  */
475 {
476  struct vlan_info *vi = link->l_info;
477 
478  IS_VLAN_LINK_ASSERT(link);
479 
480  if (vi->vi_mask & VLAN_HAS_PROTOCOL)
481  return vi->vi_protocol;
482  else
483  return 0;
484 }
485 
486 /**
487  * Set VLAN flags
488  * @arg link Link object
489  * @arg flags VLAN flags
490  *
491  * @return 0 on success or a negative error code.
492  */
493 int rtnl_link_vlan_set_flags(struct rtnl_link *link, unsigned int flags)
494 {
495  struct vlan_info *vi = link->l_info;
496 
497  IS_VLAN_LINK_ASSERT(link);
498 
499  vi->vi_flags_mask |= flags;
500  vi->vi_flags |= flags;
501  vi->vi_mask |= VLAN_HAS_FLAGS;
502 
503  return 0;
504 }
505 
506 /**
507  * Unset VLAN flags
508  * @arg link Link object
509  * @arg flags VLAN flags
510  *
511  * @return 0 on success or a negative error code.
512  */
513 int rtnl_link_vlan_unset_flags(struct rtnl_link *link, unsigned int flags)
514 {
515  struct vlan_info *vi = link->l_info;
516 
517  IS_VLAN_LINK_ASSERT(link);
518 
519  vi->vi_flags_mask |= flags;
520  vi->vi_flags &= ~flags;
521  vi->vi_mask |= VLAN_HAS_FLAGS;
522 
523  return 0;
524 }
525 
526 /**
527  * Get VLAN flags
528  * @arg link Link object
529  *
530  * @return VLAN flags, 0 if none set, or a negative error code.
531  */
533 {
534  struct vlan_info *vi = link->l_info;
535 
536  IS_VLAN_LINK_ASSERT(link);
537 
538  return vi->vi_flags;
539 }
540 
541 /** @} */
542 
543 /**
544  * @name Quality of Service
545  * @{
546  */
547 
548 int rtnl_link_vlan_set_ingress_map(struct rtnl_link *link, int from,
549  uint32_t to)
550 {
551  struct vlan_info *vi = link->l_info;
552 
553  IS_VLAN_LINK_ASSERT(link);
554 
555  if (from < 0 || from > VLAN_PRIO_MAX)
556  return -NLE_INVAL;
557 
558  vi->vi_ingress_qos_mask |= (1 << from);
559  vi->vi_ingress_qos[from] = to;
560  vi->vi_mask |= VLAN_HAS_INGRESS_QOS;
561 
562  return 0;
563 }
564 
565 uint32_t *rtnl_link_vlan_get_ingress_map(struct rtnl_link *link)
566 {
567  struct vlan_info *vi = link->l_info;
568 
569  if (link->l_info_ops != &vlan_info_ops || !link->l_info_ops)
570  return NULL;
571 
572  if (vi->vi_mask & VLAN_HAS_INGRESS_QOS)
573  return vi->vi_ingress_qos;
574  else
575  return NULL;
576 }
577 
578 int rtnl_link_vlan_set_egress_map(struct rtnl_link *link, uint32_t from, int to)
579 {
580  struct vlan_info *vi = link->l_info;
581 
582  if (link->l_info_ops != &vlan_info_ops || !link->l_info_ops)
583  return -NLE_OPNOTSUPP;
584 
585  if (to < 0 || to > VLAN_PRIO_MAX)
586  return -NLE_INVAL;
587 
588  if (vi->vi_negress >= vi->vi_egress_size) {
589  int new_size = vi->vi_egress_size + 32;
590  void *ptr;
591 
592  ptr = realloc(vi->vi_egress_qos, new_size);
593  if (!ptr)
594  return -NLE_NOMEM;
595 
596  vi->vi_egress_qos = ptr;
597  vi->vi_egress_size = new_size;
598  }
599 
600  vi->vi_egress_qos[vi->vi_negress].vm_from = from;
601  vi->vi_egress_qos[vi->vi_negress].vm_to = to;
602  vi->vi_negress++;
603  vi->vi_mask |= VLAN_HAS_EGRESS_QOS;
604 
605  return 0;
606 }
607 
608 struct vlan_map *rtnl_link_vlan_get_egress_map(struct rtnl_link *link,
609  int *negress)
610 {
611  struct vlan_info *vi = link->l_info;
612 
613  if (link->l_info_ops != &vlan_info_ops || !link->l_info_ops)
614  return NULL;
615 
616  if (negress == NULL)
617  return NULL;
618 
619  if (vi->vi_mask & VLAN_HAS_EGRESS_QOS) {
620  *negress = vi->vi_negress;
621  return vi->vi_egress_qos;
622  } else {
623  *negress = 0;
624  return NULL;
625  }
626 }
627 
628 /** @} */
629 
630 static const struct trans_tbl vlan_flags[] = {
631  __ADD(VLAN_FLAG_REORDER_HDR, reorder_hdr),
632  __ADD(VLAN_FLAG_GVRP, gvrp),
633  __ADD(VLAN_FLAG_LOOSE_BINDING, loose_binding),
634  __ADD(VLAN_FLAG_MVRP, mvrp),
635 };
636 
637 /**
638  * @name Flag Translation
639  * @{
640  */
641 
642 char *rtnl_link_vlan_flags2str(int flags, char *buf, size_t len)
643 {
644  return __flags2str(flags, buf, len, vlan_flags, ARRAY_SIZE(vlan_flags));
645 }
646 
647 int rtnl_link_vlan_str2flags(const char *name)
648 {
649  return __str2flags(name, vlan_flags, ARRAY_SIZE(vlan_flags));
650 }
651 
652 /** @} */
653 
654 
655 static void __init vlan_init(void)
656 {
657  rtnl_link_register_info(&vlan_info_ops);
658 }
659 
660 static void __exit vlan_exit(void)
661 {
662  rtnl_link_unregister_info(&vlan_info_ops);
663 }
664 
665 /** @} */
Dump object briefly on one line.
Definition: types.h:22
int rtnl_link_vlan_set_flags(struct rtnl_link *link, unsigned int flags)
Set VLAN flags.
Definition: vlan.c:493
struct rtnl_link * rtnl_link_vlan_alloc(void)
Allocate link object of type VLAN.
Definition: vlan.c:383
int rtnl_link_vlan_get_flags(struct rtnl_link *link)
Get VLAN flags.
Definition: vlan.c:532
Attribute validation policy.
Definition: attr.h:67
Dump all attributes but no statistics.
Definition: types.h:23
int nla_nest_end(struct nl_msg *msg, struct nlattr *start)
Finalize nesting of attributes.
Definition: attr.c:917
int nla_memcpy(void *dest, const struct nlattr *src, int count)
Copy attribute payload to another memory area.
Definition: attr.c:353
#define NLA_PUT(msg, attrtype, attrlen, data)
Add unspecific attribute to netlink message.
Definition: attr.h:162
int nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla, struct nla_policy *policy)
Create attribute index based on nested attribute.
Definition: attr.c:992
16 bit integer
Definition: attr.h:40
void * nla_data(const struct nlattr *nla)
Return pointer to the payload section.
Definition: attr.c:120
int rtnl_link_vlan_get_id(struct rtnl_link *link)
Get VLAN Id.
Definition: vlan.c:435
int nla_len(const struct nlattr *nla)
Return length of the payload .
Definition: attr.c:131
#define nla_for_each_nested(pos, nla, rem)
Iterate over a stream of nested attributes.
Definition: attr.h:327
int rtnl_link_vlan_get_protocol(struct rtnl_link *link)
Get VLAN protocol.
Definition: vlan.c:474
int rtnl_link_vlan_unset_flags(struct rtnl_link *link, unsigned int flags)
Unset VLAN flags.
Definition: vlan.c:513
Nested attributes.
Definition: attr.h:46
uint16_t type
Type of attribute or NLA_UNSPEC.
Definition: attr.h:69
uint16_t nla_get_u16(const struct nlattr *nla)
Return payload of 16 bit integer attribute.
Definition: attr.c:649
Dumping parameters.
Definition: types.h:33
#define NLA_PUT_U16(msg, attrtype, value)
Add 16 bit integer attribute to netlink message.
Definition: attr.h:215
Definition: vlan.h:22
int rtnl_link_vlan_set_protocol(struct rtnl_link *link, uint16_t protocol)
Set VLAN protocol.
Definition: vlan.c:455
void nl_dump(struct nl_dump_params *params, const char *fmt,...)
Dump a formatted character string.
Definition: utils.c:914
int rtnl_link_is_vlan(struct rtnl_link *link)
Check if link is a VLAN link.
Definition: vlan.c:405
struct nlattr * nla_nest_start(struct nl_msg *msg, int attrtype)
Start a new level of nested attributes.
Definition: attr.c:895
int rtnl_link_vlan_set_id(struct rtnl_link *link, uint16_t id)
Set VLAN ID.
Definition: vlan.c:417