libnl  3.2.27
ipgre.c
1 /*
2  * lib/route/link/ipgre.c IPGRE 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) 2014 Susant Sahani <susant@redhat.com>
10  */
11 
12 /**
13  * @ingroup link
14  * @defgroup ipgre IPGRE
15  * ipgre link module
16  *
17  * @details
18  * \b Link Type Name: "ipgre"
19  *
20  * @route_doc{link_ipgre, IPGRE 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/route/link/ipgre.h>
32 #include <netlink-private/route/link/api.h>
33 #include <linux/if_tunnel.h>
34 
35 #define IPGRE_ATTR_LINK (1 << 0)
36 #define IPGRE_ATTR_IFLAGS (1 << 1)
37 #define IPGRE_ATTR_OFLAGS (1 << 2)
38 #define IPGRE_ATTR_IKEY (1 << 3)
39 #define IPGRE_ATTR_OKEY (1 << 4)
40 #define IPGRE_ATTR_LOCAL (1 << 5)
41 #define IPGRE_ATTR_REMOTE (1 << 6)
42 #define IPGRE_ATTR_TTL (1 << 7)
43 #define IPGRE_ATTR_TOS (1 << 8)
44 #define IPGRE_ATTR_PMTUDISC (1 << 9)
45 
46 struct ipgre_info
47 {
48  uint8_t ttl;
49  uint8_t tos;
50  uint8_t pmtudisc;
51  uint16_t iflags;
52  uint16_t oflags;
53  uint32_t ikey;
54  uint32_t okey;
55  uint32_t link;
56  uint32_t local;
57  uint32_t remote;
58  uint32_t ipgre_mask;
59 };
60 
61 static struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
62  [IFLA_GRE_LINK] = { .type = NLA_U32 },
63  [IFLA_GRE_IFLAGS] = { .type = NLA_U16 },
64  [IFLA_GRE_OFLAGS] = { .type = NLA_U16 },
65  [IFLA_GRE_IKEY] = { .type = NLA_U32 },
66  [IFLA_GRE_OKEY] = { .type = NLA_U32 },
67  [IFLA_GRE_LOCAL] = { .type = NLA_U32 },
68  [IFLA_GRE_REMOTE] = { .type = NLA_U32 },
69  [IFLA_GRE_TTL] = { .type = NLA_U8 },
70  [IFLA_GRE_TOS] = { .type = NLA_U8 },
71  [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
72 };
73 
74 static int ipgre_alloc(struct rtnl_link *link)
75 {
76  struct ipgre_info *ipgre;
77 
78  if (link->l_info)
79  memset(link->l_info, 0, sizeof(*ipgre));
80  else {
81  ipgre = calloc(1, sizeof(*ipgre));
82  if (!ipgre)
83  return -NLE_NOMEM;
84 
85  link->l_info = ipgre;
86  }
87 
88  return 0;
89 }
90 
91 static int ipgre_parse(struct rtnl_link *link, struct nlattr *data,
92  struct nlattr *xstats)
93 {
94  struct nlattr *tb[IFLA_IPTUN_MAX + 1];
95  struct ipgre_info *ipgre;
96  int err;
97 
98  NL_DBG(3, "Parsing IPGRE link info\n");
99 
100  err = nla_parse_nested(tb, IFLA_GRE_MAX, data, ipgre_policy);
101  if (err < 0)
102  goto errout;
103 
104  err = ipgre_alloc(link);
105  if (err < 0)
106  goto errout;
107 
108  ipgre = link->l_info;
109 
110  if (tb[IFLA_GRE_LINK]) {
111  ipgre->link = nla_get_u32(tb[IFLA_GRE_LINK]);
112  ipgre->ipgre_mask |= IPGRE_ATTR_LINK;
113  }
114 
115  if (tb[IFLA_GRE_IFLAGS]) {
116  ipgre->iflags = nla_get_u16(tb[IFLA_GRE_IFLAGS]);
117  ipgre->ipgre_mask |= IPGRE_ATTR_IFLAGS;
118  }
119 
120  if (tb[IFLA_GRE_OFLAGS]) {
121  ipgre->oflags = nla_get_u16(tb[IFLA_GRE_OFLAGS]);
122  ipgre->ipgre_mask |= IPGRE_ATTR_OFLAGS;
123  }
124 
125  if (tb[IFLA_GRE_IKEY]) {
126  ipgre->ikey = nla_get_u32(tb[IFLA_GRE_IKEY]);
127  ipgre->ipgre_mask |= IPGRE_ATTR_IKEY;
128  }
129 
130  if (tb[IFLA_GRE_OKEY]) {
131  ipgre->okey = nla_get_u32(tb[IFLA_GRE_OKEY]);
132  ipgre->ipgre_mask |= IPGRE_ATTR_OKEY;
133  }
134 
135  if (tb[IFLA_GRE_LOCAL]) {
136  ipgre->local = nla_get_u32(tb[IFLA_GRE_LOCAL]);
137  ipgre->ipgre_mask |= IPGRE_ATTR_LOCAL;
138  }
139 
140  if (tb[IFLA_GRE_LOCAL]) {
141  ipgre->remote = nla_get_u32(tb[IFLA_GRE_LOCAL]);
142  ipgre->ipgre_mask |= IPGRE_ATTR_REMOTE;
143  }
144 
145  if (tb[IFLA_GRE_TTL]) {
146  ipgre->ttl = nla_get_u8(tb[IFLA_GRE_TTL]);
147  ipgre->ipgre_mask |= IPGRE_ATTR_TTL;
148  }
149 
150  if (tb[IFLA_GRE_TOS]) {
151  ipgre->tos = nla_get_u8(tb[IFLA_GRE_TOS]);
152  ipgre->ipgre_mask |= IPGRE_ATTR_TOS;
153  }
154 
155  if (tb[IFLA_GRE_PMTUDISC]) {
156  ipgre->pmtudisc = nla_get_u8(tb[IFLA_GRE_PMTUDISC]);
157  ipgre->ipgre_mask |= IPGRE_ATTR_PMTUDISC;
158  }
159 
160  err = 0;
161 
162  errout:
163  return err;
164 }
165 
166 static int ipgre_put_attrs(struct nl_msg *msg, struct rtnl_link *link)
167 {
168  struct ipgre_info *ipgre = link->l_info;
169  struct nlattr *data;
170 
171  data = nla_nest_start(msg, IFLA_INFO_DATA);
172  if (!data)
173  return -NLE_MSGSIZE;
174 
175  if (ipgre->ipgre_mask & IPGRE_ATTR_LINK)
176  NLA_PUT_U32(msg, IFLA_GRE_LINK, ipgre->link);
177 
178  if (ipgre->ipgre_mask & IFLA_GRE_IFLAGS)
179  NLA_PUT_U16(msg, IFLA_GRE_IFLAGS, ipgre->iflags);
180 
181  if (ipgre->ipgre_mask & IFLA_GRE_OFLAGS)
182  NLA_PUT_U16(msg, IFLA_GRE_OFLAGS, ipgre->oflags);
183 
184  if (ipgre->ipgre_mask & IPGRE_ATTR_IKEY)
185  NLA_PUT_U32(msg, IFLA_GRE_IKEY, ipgre->ikey);
186 
187  if (ipgre->ipgre_mask & IPGRE_ATTR_OKEY)
188  NLA_PUT_U32(msg, IFLA_GRE_OKEY, ipgre->okey);
189 
190  if (ipgre->ipgre_mask & IPGRE_ATTR_LOCAL)
191  NLA_PUT_U32(msg, IFLA_GRE_LOCAL, ipgre->local);
192 
193  if (ipgre->ipgre_mask & IPGRE_ATTR_REMOTE)
194  NLA_PUT_U32(msg, IFLA_GRE_REMOTE, ipgre->remote);
195 
196  if (ipgre->ipgre_mask & IPGRE_ATTR_TTL)
197  NLA_PUT_U8(msg, IFLA_GRE_TTL, ipgre->ttl);
198 
199  if (ipgre->ipgre_mask & IPGRE_ATTR_TOS)
200  NLA_PUT_U8(msg, IFLA_GRE_TOS, ipgre->tos);
201 
202  if (ipgre->ipgre_mask & IPGRE_ATTR_PMTUDISC)
203  NLA_PUT_U8(msg, IFLA_GRE_PMTUDISC, ipgre->pmtudisc);
204 
205  nla_nest_end(msg, data);
206 
207  nla_put_failure:
208 
209  return 0;
210 }
211 
212 static void ipgre_free(struct rtnl_link *link)
213 {
214  struct ipgre_info *ipgre = link->l_info;
215 
216  free(ipgre);
217  link->l_info = NULL;
218 }
219 
220 static void ipgre_dump_line(struct rtnl_link *link, struct nl_dump_params *p)
221 {
222  nl_dump(p, "ipgre : %s", link->l_name);
223 }
224 
225 static void ipgre_dump_details(struct rtnl_link *link, struct nl_dump_params *p)
226 {
227  struct ipgre_info *ipgre = link->l_info;
228  char *name, addr[INET_ADDRSTRLEN];
229 
230  if (ipgre->ipgre_mask & IPGRE_ATTR_LINK) {
231  nl_dump(p, " link ");
232  name = rtnl_link_get_name(link);
233  if (name)
234  nl_dump_line(p, "%s\n", name);
235  else
236  nl_dump_line(p, "%u\n", ipgre->link);
237  }
238 
239  if (ipgre->ipgre_mask & IPGRE_ATTR_IFLAGS) {
240  nl_dump(p, " iflags ");
241  nl_dump_line(p, "%x\n", ipgre->iflags);
242  }
243 
244  if (ipgre->ipgre_mask & IPGRE_ATTR_OFLAGS) {
245  nl_dump(p, " oflags ");
246  nl_dump_line(p, "%x\n", ipgre->oflags);
247  }
248 
249  if (ipgre->ipgre_mask & IPGRE_ATTR_IKEY) {
250  nl_dump(p, " ikey ");
251  nl_dump_line(p, "%x\n",ipgre->ikey);
252  }
253 
254  if (ipgre->ipgre_mask & IPGRE_ATTR_OKEY) {
255  nl_dump(p, " okey ");
256  nl_dump_line(p, "%x\n", ipgre->okey);
257  }
258 
259  if (ipgre->ipgre_mask & IPGRE_ATTR_LOCAL) {
260  nl_dump(p, " local ");
261  if(inet_ntop(AF_INET, &ipgre->local, addr, sizeof(addr)))
262  nl_dump_line(p, "%s\n", addr);
263  else
264  nl_dump_line(p, "%#x\n", ntohs(ipgre->local));
265  }
266 
267  if (ipgre->ipgre_mask & IPGRE_ATTR_REMOTE) {
268  nl_dump(p, " remote ");
269  if(inet_ntop(AF_INET, &ipgre->remote, addr, sizeof(addr)))
270  nl_dump_line(p, "%s\n", addr);
271  else
272  nl_dump_line(p, "%#x\n", ntohs(ipgre->remote));
273  }
274 
275  if (ipgre->ipgre_mask & IPGRE_ATTR_TTL) {
276  nl_dump(p, " ttl ");
277  nl_dump_line(p, "%u\n", ipgre->ttl);
278  }
279 
280  if (ipgre->ipgre_mask & IPGRE_ATTR_TOS) {
281  nl_dump(p, " tos ");
282  nl_dump_line(p, "%u\n", ipgre->tos);
283  }
284 
285  if (ipgre->ipgre_mask & IPGRE_ATTR_PMTUDISC) {
286  nl_dump(p, " pmtudisc ");
287  nl_dump_line(p, "enabled (%#x)\n", ipgre->pmtudisc);
288  }
289 }
290 
291 static int ipgre_clone(struct rtnl_link *dst, struct rtnl_link *src)
292 {
293  struct ipgre_info *ipgre_dst, *ipgre_src = src->l_info;
294  int err;
295 
296  dst->l_info = NULL;
297 
298  err = rtnl_link_set_type(dst, "gre");
299  if (err < 0)
300  return err;
301 
302  ipgre_dst = dst->l_info;
303 
304  if (!ipgre_dst || !ipgre_src)
305  BUG();
306 
307  memcpy(ipgre_dst, ipgre_src, sizeof(struct ipgre_info));
308 
309  return 0;
310 }
311 
312 static struct rtnl_link_info_ops ipgre_info_ops = {
313  .io_name = "gre",
314  .io_alloc = ipgre_alloc,
315  .io_parse = ipgre_parse,
316  .io_dump = {
317  [NL_DUMP_LINE] = ipgre_dump_line,
318  [NL_DUMP_DETAILS] = ipgre_dump_details,
319  },
320  .io_clone = ipgre_clone,
321  .io_put_attrs = ipgre_put_attrs,
322  .io_free = ipgre_free,
323 };
324 
325 #define IS_IPGRE_LINK_ASSERT(link) \
326  if ((link)->l_info_ops != &ipgre_info_ops) { \
327  APPBUG("Link is not a ipgre link. set type \"gre\" first.");\
328  return -NLE_OPNOTSUPP; \
329  }
330 
331 struct rtnl_link *rtnl_link_ipgre_alloc(void)
332 {
333  struct rtnl_link *link;
334  int err;
335 
336  link = rtnl_link_alloc();
337  if (!link)
338  return NULL;
339 
340  err = rtnl_link_set_type(link, "gre");
341  if (err < 0) {
342  rtnl_link_put(link);
343  return NULL;
344  }
345 
346  return link;
347 }
348 
349 /**
350  * Check if link is a IPGRE link
351  * @arg link Link object
352  *
353  * @return True if link is a IPGRE link, otherwise 0 is returned.
354  */
355 int rtnl_link_is_ipgre(struct rtnl_link *link)
356 {
357  return link->l_info_ops && !strcmp(link->l_info_ops->io_name, "gre");
358 }
359 /**
360  * Create a new ipip tunnel device
361  * @arg sock netlink socket
362  * @arg name name of the tunnel deviceL
363  *
364  * Creates a new ipip tunnel device in the kernel
365  * @return 0 on success or a negative error code
366  */
367 int rtnl_link_ipgre_add(struct nl_sock *sk, const char *name)
368 {
369  struct rtnl_link *link;
370  int err;
371 
372  link = rtnl_link_ipgre_alloc();
373  if (!link)
374  return -NLE_NOMEM;
375 
376  if(name)
377  rtnl_link_set_name(link, name);
378 
379  err = rtnl_link_add(sk, link, NLM_F_CREATE);
380  rtnl_link_put(link);
381 
382  return err;
383 }
384 /**
385  * Set IPGRE tunnel interface index
386  * @arg link Link object
387  * @arg index interface index
388  *
389  * @return 0 on success or a negative error code
390  */
391 int rtnl_link_ipgre_set_link(struct rtnl_link *link, uint32_t index)
392 {
393  struct ipgre_info *ipgre = link->l_info;
394 
395  IS_IPGRE_LINK_ASSERT(link);
396 
397  ipgre->link = index;
398  ipgre->ipgre_mask |= IPGRE_ATTR_LINK;
399 
400  return 0;
401 }
402 
403 /**
404  * Get IPGRE tunnel interface index
405  * @arg link Link object
406  *
407  * @return interface index
408  */
409 uint32_t rtnl_link_ipgre_get_link(struct rtnl_link *link)
410 {
411  struct ipgre_info *ipgre = link->l_info;
412 
413  IS_IPGRE_LINK_ASSERT(link);
414 
415  return ipgre->link;
416 }
417 
418 /**
419  * Set IPGRE tunnel set iflags
420  * @arg link Link object
421  * @arg iflags gre iflags
422  *
423  * @return 0 on success or a negative error code
424  */
425 int rtnl_link_ipgre_set_iflags(struct rtnl_link *link, uint16_t iflags)
426 {
427  struct ipgre_info *ipgre = link->l_info;
428 
429  IS_IPGRE_LINK_ASSERT(link);
430 
431  ipgre->iflags = iflags;
432  ipgre->ipgre_mask |= IPGRE_ATTR_IFLAGS;
433 
434  return 0;
435 }
436 
437 /**
438  * Get IPGRE tunnel iflags
439  * @arg link Link object
440  *
441  * @return iflags
442  */
443 uint16_t rtnl_link_ipgre_get_iflags(struct rtnl_link *link)
444 {
445  struct ipgre_info *ipgre = link->l_info;
446 
447  IS_IPGRE_LINK_ASSERT(link);
448 
449  return ipgre->iflags;
450 }
451 
452 /**
453  * Set IPGRE tunnel set oflags
454  * @arg link Link object
455  * @arg iflags gre oflags
456  *
457  * @return 0 on success or a negative error code
458  */
459 int rtnl_link_ipgre_set_oflags(struct rtnl_link *link, uint16_t oflags)
460 {
461  struct ipgre_info *ipgre = link->l_info;
462 
463  IS_IPGRE_LINK_ASSERT(link);
464 
465  ipgre->oflags = oflags;
466  ipgre->ipgre_mask |= IPGRE_ATTR_OFLAGS;
467 
468  return 0;
469 }
470 
471 /**
472  * Get IPGRE tunnel oflags
473  * @arg link Link object
474  *
475  * @return oflags
476  */
477 uint16_t rtnl_link_ipgre_get_oflags(struct rtnl_link *link)
478 {
479  struct ipgre_info *ipgre = link->l_info;
480 
481  IS_IPGRE_LINK_ASSERT(link);
482 
483  return ipgre->oflags;
484 }
485 
486 /**
487  * Set IPGRE tunnel set ikey
488  * @arg link Link object
489  * @arg ikey gre ikey
490  *
491  * @return 0 on success or a negative error code
492  */
493 int rtnl_link_ipgre_set_ikey(struct rtnl_link *link, uint32_t ikey)
494 {
495  struct ipgre_info *ipgre = link->l_info;
496 
497  IS_IPGRE_LINK_ASSERT(link);
498 
499  ipgre->ikey = ikey;
500  ipgre->ipgre_mask |= IPGRE_ATTR_IKEY;
501 
502  return 0;
503 }
504 
505 /**
506  * Get IPGRE tunnel ikey
507  * @arg link Link object
508  *
509  * @return ikey
510  */
511 uint32_t rtnl_link_ipgre_get_ikey(struct rtnl_link *link)
512 {
513  struct ipgre_info *ipgre = link->l_info;
514 
515  IS_IPGRE_LINK_ASSERT(link);
516 
517  return ipgre->ikey;
518 }
519 
520 /**
521  * Set IPGRE tunnel set okey
522  * @arg link Link object
523  * @arg okey gre okey
524  *
525  * @return 0 on success or a negative error code
526  */
527 int rtnl_link_ipgre_set_okey(struct rtnl_link *link, uint32_t okey)
528 {
529  struct ipgre_info *ipgre = link->l_info;
530 
531  IS_IPGRE_LINK_ASSERT(link);
532 
533  ipgre->okey = okey;
534  ipgre->ipgre_mask |= IPGRE_ATTR_OKEY;
535 
536  return 0;
537 }
538 
539 /**
540  * Get IPGRE tunnel okey
541  * @arg link Link object
542  *
543  * @return okey value
544  */
545 uint32_t rtnl_link_ipgre_get_okey(struct rtnl_link *link)
546 {
547  struct ipgre_info *ipgre = link->l_info;
548 
549  IS_IPGRE_LINK_ASSERT(link);
550 
551  return ipgre->okey;
552 }
553 
554 /**
555  * Set IPGRE tunnel local address
556  * @arg link Link object
557  * @arg addr local address
558  *
559  * @return 0 on success or a negative error code
560  */
561 int rtnl_link_ipgre_set_local(struct rtnl_link *link, uint32_t addr)
562 {
563  struct ipgre_info *ipgre = link->l_info;
564 
565  IS_IPGRE_LINK_ASSERT(link);
566 
567  ipgre->local = addr;
568  ipgre->ipgre_mask |= IPGRE_ATTR_LOCAL;
569 
570  return 0;
571 }
572 
573 /**
574  * Get IPGRE tunnel local address
575  * @arg link Link object
576  *
577  * @return local address
578  */
579 uint32_t rtnl_link_ipgre_get_local(struct rtnl_link *link)
580 {
581  struct ipgre_info *ipgre = link->l_info;
582 
583  IS_IPGRE_LINK_ASSERT(link);
584 
585  return ipgre->local;
586 }
587 
588 /**
589  * Set IPGRE tunnel remote address
590  * @arg link Link object
591  * @arg remote remote address
592  *
593  * @return 0 on success or a negative error code
594  */
595 int rtnl_link_ipgre_set_remote(struct rtnl_link *link, uint32_t remote)
596 {
597  struct ipgre_info *ipgre = link->l_info;
598 
599  IS_IPGRE_LINK_ASSERT(link);
600 
601  ipgre->remote = remote;
602  ipgre->ipgre_mask |= IPGRE_ATTR_REMOTE;
603 
604  return 0;
605 }
606 
607 /**
608  * Get IPGRE tunnel remote address
609  * @arg link Link object
610  *
611  * @return remote address on success or a negative error code
612  */
613 uint32_t rtnl_link_ipgre_get_remote(struct rtnl_link *link)
614 {
615  struct ipgre_info *ipgre = link->l_info;
616 
617  IS_IPGRE_LINK_ASSERT(link);
618 
619  return ipgre->remote;
620 }
621 
622 /**
623  * Set IPGRE tunnel ttl
624  * @arg link Link object
625  * @arg ttl tunnel ttl
626  *
627  * @return 0 on success or a negative error code
628  */
629 int rtnl_link_ipgre_set_ttl(struct rtnl_link *link, uint8_t ttl)
630 {
631  struct ipgre_info *ipgre = link->l_info;
632 
633  IS_IPGRE_LINK_ASSERT(link);
634 
635  ipgre->ttl = ttl;
636  ipgre->ipgre_mask |= IPGRE_ATTR_TTL;
637 
638  return 0;
639 }
640 
641 /**
642  * Set IPGRE tunnel ttl
643  * @arg link Link object
644  *
645  * @return ttl value
646  */
647 uint8_t rtnl_link_ipgre_get_ttl(struct rtnl_link *link)
648 {
649  struct ipgre_info *ipgre = link->l_info;
650 
651  IS_IPGRE_LINK_ASSERT(link);
652 
653  return ipgre->ttl;
654 }
655 
656 /**
657  * Set IPGRE tunnel tos
658  * @arg link Link object
659  * @arg tos tunnel tos
660  *
661  * @return 0 on success or a negative error code
662  */
663 int rtnl_link_ipgre_set_tos(struct rtnl_link *link, uint8_t tos)
664 {
665  struct ipgre_info *ipgre = link->l_info;
666 
667  IS_IPGRE_LINK_ASSERT(link);
668 
669  ipgre->tos = tos;
670  ipgre->ipgre_mask |= IPGRE_ATTR_TOS;
671 
672  return 0;
673 }
674 
675 /**
676  * Get IPGRE tunnel tos
677  * @arg link Link object
678  *
679  * @return tos value
680  */
681 uint8_t rtnl_link_ipgre_get_tos(struct rtnl_link *link)
682 {
683  struct ipgre_info *ipgre = link->l_info;
684 
685  IS_IPGRE_LINK_ASSERT(link);
686 
687  return ipgre->tos;
688 }
689 
690 /**
691  * Set IPGRE tunnel path MTU discovery
692  * @arg link Link object
693  * @arg pmtudisc path MTU discovery
694  *
695  * @return 0 on success or a negative error code
696  */
697 int rtnl_link_ipgre_set_pmtudisc(struct rtnl_link *link, uint8_t pmtudisc)
698 {
699  struct ipgre_info *ipgre = link->l_info;
700 
701  IS_IPGRE_LINK_ASSERT(link);
702 
703  ipgre->pmtudisc = pmtudisc;
704  ipgre->ipgre_mask |= IPGRE_ATTR_PMTUDISC;
705 
706  return 0;
707 }
708 
709 /**
710  * Get IPGRE path MTU discovery
711  * @arg link Link object
712  *
713  * @return pmtudisc value
714  */
715 uint8_t rtnl_link_get_pmtudisc(struct rtnl_link *link)
716 {
717  struct ipgre_info *ipgre = link->l_info;
718 
719  IS_IPGRE_LINK_ASSERT(link);
720 
721  return ipgre->pmtudisc;
722 }
723 
724 static void __init ipgre_init(void)
725 {
726  rtnl_link_register_info(&ipgre_info_ops);
727 }
728 
729 static void __exit ipgre_exit(void)
730 {
731  rtnl_link_unregister_info(&ipgre_info_ops);
732 }
Dump object briefly on one line.
Definition: types.h:22
8 bit integer
Definition: attr.h:39
uint8_t rtnl_link_ipgre_get_ttl(struct rtnl_link *link)
Set IPGRE tunnel ttl.
Definition: ipgre.c:647
int rtnl_link_is_ipgre(struct rtnl_link *link)
Check if link is a IPGRE link.
Definition: ipgre.c:355
int rtnl_link_ipgre_set_tos(struct rtnl_link *link, uint8_t tos)
Set IPGRE tunnel tos.
Definition: ipgre.c:663
int rtnl_link_ipgre_set_ikey(struct rtnl_link *link, uint32_t ikey)
Set IPGRE tunnel set ikey.
Definition: ipgre.c:493
Attribute validation policy.
Definition: attr.h:67
uint8_t nla_get_u8(const struct nlattr *nla)
Return value of 8 bit integer attribute.
Definition: attr.c:599
int rtnl_link_ipgre_set_link(struct rtnl_link *link, uint32_t index)
Set IPGRE tunnel interface index.
Definition: ipgre.c:391
uint32_t rtnl_link_ipgre_get_ikey(struct rtnl_link *link)
Get IPGRE tunnel ikey.
Definition: ipgre.c:511
uint32_t rtnl_link_ipgre_get_link(struct rtnl_link *link)
Get IPGRE tunnel interface index.
Definition: ipgre.c:409
uint32_t nla_get_u32(const struct nlattr *nla)
Return payload of 32 bit integer attribute.
Definition: attr.c:699
uint8_t rtnl_link_ipgre_get_tos(struct rtnl_link *link)
Get IPGRE tunnel tos.
Definition: ipgre.c:681
int rtnl_link_ipgre_set_iflags(struct rtnl_link *link, uint16_t iflags)
Set IPGRE tunnel set iflags.
Definition: ipgre.c:425
#define NLA_PUT_U8(msg, attrtype, value)
Add 8 bit integer attribute to netlink message.
Definition: attr.h:197
uint16_t rtnl_link_ipgre_get_oflags(struct rtnl_link *link)
Get IPGRE tunnel oflags.
Definition: ipgre.c:477
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
uint32_t rtnl_link_ipgre_get_local(struct rtnl_link *link)
Get IPGRE tunnel local address.
Definition: ipgre.c:579
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:991
16 bit integer
Definition: attr.h:40
int rtnl_link_ipgre_set_local(struct rtnl_link *link, uint32_t addr)
Set IPGRE tunnel local address.
Definition: ipgre.c:561
#define NLA_PUT_U32(msg, attrtype, value)
Add 32 bit integer attribute to netlink message.
Definition: attr.h:233
uint32_t rtnl_link_ipgre_get_okey(struct rtnl_link *link)
Get IPGRE tunnel okey.
Definition: ipgre.c:545
int rtnl_link_ipgre_set_pmtudisc(struct rtnl_link *link, uint8_t pmtudisc)
Set IPGRE tunnel path MTU discovery.
Definition: ipgre.c:697
int rtnl_link_ipgre_add(struct nl_sock *sk, const char *name)
Create a new ipip tunnel device.
Definition: ipgre.c:367
uint32_t rtnl_link_ipgre_get_remote(struct rtnl_link *link)
Get IPGRE tunnel remote address.
Definition: ipgre.c:613
int rtnl_link_ipgre_set_okey(struct rtnl_link *link, uint32_t okey)
Set IPGRE tunnel set okey.
Definition: ipgre.c:527
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
32 bit integer
Definition: attr.h:41
uint16_t rtnl_link_ipgre_get_iflags(struct rtnl_link *link)
Get IPGRE tunnel iflags.
Definition: ipgre.c:443
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
int rtnl_link_ipgre_set_ttl(struct rtnl_link *link, uint8_t ttl)
Set IPGRE tunnel ttl.
Definition: ipgre.c:629
void nl_dump(struct nl_dump_params *params, const char *fmt,...)
Dump a formatted character string.
Definition: utils.c:914
uint8_t rtnl_link_get_pmtudisc(struct rtnl_link *link)
Get IPGRE path MTU discovery.
Definition: ipgre.c:715
int rtnl_link_ipgre_set_remote(struct rtnl_link *link, uint32_t remote)
Set IPGRE tunnel remote address.
Definition: ipgre.c:595
int rtnl_link_ipgre_set_oflags(struct rtnl_link *link, uint16_t oflags)
Set IPGRE tunnel set oflags.
Definition: ipgre.c:459
struct nlattr * nla_nest_start(struct nl_msg *msg, int attrtype)
Start a new level of nested attributes.
Definition: attr.c:895