]> git.proxmox.com Git - mirror_iproute2.git/blob - tc/m_pedit.c
pedit: fix whitespace
[mirror_iproute2.git] / tc / m_pedit.c
1 /*
2 * m_pedit.c generic packet editor actions module
3 *
4 * This program is free software; you can distribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * Authors: J Hadi Salim (hadi@cyberus.ca)
10 *
11 * TODO:
12 * 1) Big endian broken in some spots
13 * 2) A lot of this stuff was added on the fly; get a big double-double
14 * and clean it up at some point.
15 *
16 */
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <unistd.h>
21 #include <syslog.h>
22 #include <fcntl.h>
23 #include <sys/socket.h>
24 #include <netinet/in.h>
25 #include <arpa/inet.h>
26 #include <string.h>
27 #include <dlfcn.h>
28 #include "utils.h"
29 #include "tc_util.h"
30 #include "m_pedit.h"
31 #include "rt_names.h"
32
33 static struct m_pedit_util *pedit_list;
34 static int pedit_debug;
35
36 static void explain(void)
37 {
38 fprintf(stderr, "Usage: ... pedit munge [ex] <MUNGE> [CONTROL]\n");
39 fprintf(stderr,
40 "Where: MUNGE := <RAW>|<LAYERED>\n"
41 "\t<RAW>:= <OFFSETC>[ATC]<CMD>\n \t\tOFFSETC:= offset <offval> <u8|u16|u32>\n"
42 "\t\tATC:= at <atval> offmask <maskval> shift <shiftval>\n"
43 "\t\tNOTE: offval is byte offset, must be multiple of 4\n"
44 "\t\tNOTE: maskval is a 32 bit hex number\n \t\tNOTE: shiftval is a shift value\n"
45 "\t\tCMD:= clear | invert | set <setval>| add <addval> | retain\n"
46 "\t<LAYERED>:= ip <ipdata> | ip6 <ip6data>\n"
47 " \t\t| udp <udpdata> | tcp <tcpdata> | icmp <icmpdata>\n"
48 "\tCONTROL:= reclassify | pipe | drop | continue | pass\n"
49 "\tNOTE: if 'ex' is set, extended functionality will be supported (kernel >= 4.11)\n"
50 "For Example usage look at the examples directory\n");
51
52 }
53
54 static void usage(void)
55 {
56 explain();
57 exit(-1);
58 }
59
60 static int pedit_parse_nopopt(int *argc_p, char ***argv_p,
61 struct m_pedit_sel *sel,
62 struct m_pedit_key *tkey)
63 {
64 int argc = *argc_p;
65 char **argv = *argv_p;
66
67 if (argc) {
68 fprintf(stderr,
69 "Unknown action hence option \"%s\" is unparsable\n",
70 *argv);
71 return -1;
72 }
73
74 return 0;
75
76 }
77
78 static struct m_pedit_util *get_pedit_kind(const char *str)
79 {
80 static void *pBODY;
81 void *dlh;
82 char buf[256];
83 struct m_pedit_util *p;
84
85 for (p = pedit_list; p; p = p->next) {
86 if (strcmp(p->id, str) == 0)
87 return p;
88 }
89
90 snprintf(buf, sizeof(buf), "p_%s.so", str);
91 dlh = dlopen(buf, RTLD_LAZY);
92 if (dlh == NULL) {
93 dlh = pBODY;
94 if (dlh == NULL) {
95 dlh = pBODY = dlopen(NULL, RTLD_LAZY);
96 if (dlh == NULL)
97 goto noexist;
98 }
99 }
100
101 snprintf(buf, sizeof(buf), "p_pedit_%s", str);
102 p = dlsym(dlh, buf);
103 if (p == NULL)
104 goto noexist;
105
106 reg:
107 p->next = pedit_list;
108 pedit_list = p;
109 return p;
110
111 noexist:
112 p = calloc(1, sizeof(*p));
113 if (p) {
114 strncpy(p->id, str, sizeof(p->id) - 1);
115 p->parse_peopt = pedit_parse_nopopt;
116 goto reg;
117 }
118 return p;
119 }
120
121 int pack_key(struct m_pedit_sel *_sel, struct m_pedit_key *tkey)
122 {
123 struct tc_pedit_sel *sel = &_sel->sel;
124 struct m_pedit_key_ex *keys_ex = _sel->keys_ex;
125 int hwm = sel->nkeys;
126
127 if (hwm >= MAX_OFFS)
128 return -1;
129
130 if (tkey->off % 4) {
131 fprintf(stderr, "offsets MUST be in 32 bit boundaries\n");
132 return -1;
133 }
134
135 sel->keys[hwm].val = tkey->val;
136 sel->keys[hwm].mask = tkey->mask;
137 sel->keys[hwm].off = tkey->off;
138 sel->keys[hwm].at = tkey->at;
139 sel->keys[hwm].offmask = tkey->offmask;
140 sel->keys[hwm].shift = tkey->shift;
141
142 if (_sel->extended) {
143 keys_ex[hwm].htype = tkey->htype;
144 keys_ex[hwm].cmd = tkey->cmd;
145 } else {
146 if (tkey->htype != TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK ||
147 tkey->cmd != TCA_PEDIT_KEY_EX_CMD_SET) {
148 fprintf(stderr,
149 "Munge parameters not supported. Use 'munge ex'.\n");
150 return -1;
151 }
152 }
153
154 sel->nkeys++;
155 return 0;
156 }
157
158 int pack_key32(__u32 retain, struct m_pedit_sel *sel,
159 struct m_pedit_key *tkey)
160 {
161 if (tkey->off > (tkey->off & ~3)) {
162 fprintf(stderr,
163 "pack_key32: 32 bit offsets must begin in 32bit boundaries\n");
164 return -1;
165 }
166
167 tkey->val = htonl(tkey->val & retain);
168 tkey->mask = htonl(tkey->mask | ~retain);
169 return pack_key(sel, tkey);
170 }
171
172 int pack_key16(__u32 retain, struct m_pedit_sel *sel,
173 struct m_pedit_key *tkey)
174 {
175 int ind, stride;
176 __u32 m[4] = { 0x0000FFFF, 0xFF0000FF, 0xFFFF0000 };
177
178 if (tkey->val > 0xFFFF || tkey->mask > 0xFFFF) {
179 fprintf(stderr, "pack_key16 bad value\n");
180 return -1;
181 }
182
183 ind = tkey->off & 3;
184
185 if (ind == 3) {
186 fprintf(stderr, "pack_key16 bad index value %d\n", ind);
187 return -1;
188 }
189
190 stride = 8 * (2 - ind);
191 tkey->val = htonl((tkey->val & retain) << stride);
192 tkey->mask = htonl(((tkey->mask | ~retain) << stride) | m[ind]);
193
194 tkey->off &= ~3;
195
196 if (pedit_debug)
197 printf("pack_key16: Final val %08x mask %08x\n",
198 tkey->val, tkey->mask);
199 return pack_key(sel, tkey);
200
201 }
202
203 int pack_key8(__u32 retain, struct m_pedit_sel *sel, struct m_pedit_key *tkey)
204 {
205 int ind, stride;
206 __u32 m[4] = { 0x00FFFFFF, 0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00 };
207
208 if (tkey->val > 0xFF || tkey->mask > 0xFF) {
209 fprintf(stderr, "pack_key8 bad value (val %x mask %x\n",
210 tkey->val, tkey->mask);
211 return -1;
212 }
213
214 ind = tkey->off & 3;
215
216 stride = 8 * (3 - ind);
217 tkey->val = htonl((tkey->val & retain) << stride);
218 tkey->mask = htonl(((tkey->mask | ~retain) << stride) | m[ind]);
219
220 tkey->off &= ~3;
221
222 if (pedit_debug)
223 printf("pack_key8: Final word off %d val %08x mask %08x\n",
224 tkey->off, tkey->val, tkey->mask);
225 return pack_key(sel, tkey);
226 }
227
228 static int pack_mac(struct m_pedit_sel *sel, struct m_pedit_key *tkey,
229 __u8 *mac)
230 {
231 int ret = 0;
232
233 if (!(tkey->off & 0x3)) {
234 tkey->mask = 0;
235 tkey->val = ntohl(*((__u32 *)mac));
236 ret |= pack_key32(~0, sel, tkey);
237
238 tkey->off += 4;
239 tkey->mask = 0;
240 tkey->val = ntohs(*((__u16 *)&mac[4]));
241 ret |= pack_key16(~0, sel, tkey);
242 } else if (!(tkey->off & 0x1)) {
243 tkey->mask = 0;
244 tkey->val = ntohs(*((__u16 *)mac));
245 ret |= pack_key16(~0, sel, tkey);
246
247 tkey->off += 4;
248 tkey->mask = 0;
249 tkey->val = ntohl(*((__u32 *)(mac + 2)));
250 ret |= pack_key32(~0, sel, tkey);
251 } else {
252 fprintf(stderr,
253 "pack_mac: mac offsets must begin in 32bit or 16bit boundaries\n");
254 return -1;
255 }
256
257 return ret;
258 }
259
260 int parse_val(int *argc_p, char ***argv_p, __u32 *val, int type)
261 {
262 int argc = *argc_p;
263 char **argv = *argv_p;
264
265 if (argc <= 0)
266 return -1;
267
268 if (type == TINT)
269 return get_integer((int *)val, *argv, 0);
270
271 if (type == TU32)
272 return get_u32(val, *argv, 0);
273
274 if (type == TIPV4) {
275 inet_prefix addr;
276
277 if (get_prefix_1(&addr, *argv, AF_INET))
278 return -1;
279
280 *val = addr.data[0];
281 return 0;
282 }
283
284 if (type == TIPV6)
285 return -1; /* not implemented yet */
286
287 if (type == TMAC) {
288 #define MAC_ALEN 6
289 int ret = ll_addr_a2n((char *)val, MAC_ALEN, *argv);
290
291 if (ret == MAC_ALEN)
292 return 0;
293 }
294
295 return -1;
296 }
297
298 int parse_cmd(int *argc_p, char ***argv_p, __u32 len, int type, __u32 retain,
299 struct m_pedit_sel *sel, struct m_pedit_key *tkey)
300 {
301 __u32 mask[4] = { 0 };
302 __u32 val[4] = { 0 };
303 __u32 *m = &mask[0];
304 __u32 *v = &val[0];
305 __u32 o = 0xFF;
306 int res = -1;
307 int argc = *argc_p;
308 char **argv = *argv_p;
309
310 if (argc <= 0)
311 return -1;
312
313 if (pedit_debug)
314 printf("parse_cmd argc %d %s offset %d length %d\n",
315 argc, *argv, tkey->off, len);
316
317 if (len == 2)
318 o = 0xFFFF;
319 if (len == 4)
320 o = 0xFFFFFFFF;
321
322 if (matches(*argv, "invert") == 0) {
323 *v = *m = o;
324 } else if (matches(*argv, "set") == 0 ||
325 matches(*argv, "add") == 0) {
326 if (matches(*argv, "add") == 0)
327 tkey->cmd = TCA_PEDIT_KEY_EX_CMD_ADD;
328
329 if (!sel->extended && tkey->cmd) {
330 fprintf(stderr,
331 "Non extended mode. only 'set' command is supported\n");
332 return -1;
333 }
334
335 NEXT_ARG();
336 if (parse_val(&argc, &argv, val, type))
337 return -1;
338 } else if (matches(*argv, "preserve") == 0) {
339 retain = 0;
340 } else {
341 if (matches(*argv, "clear") != 0)
342 return -1;
343 }
344
345 argc--;
346 argv++;
347
348 if (argc && matches(*argv, "retain") == 0) {
349 NEXT_ARG();
350 if (parse_val(&argc, &argv, &retain, TU32))
351 return -1;
352 argc--;
353 argv++;
354 }
355
356 if (type == TMAC) {
357 res = pack_mac(sel, tkey, (__u8 *)val);
358 goto done;
359 }
360
361 tkey->val = *v;
362 tkey->mask = *m;
363
364 if (type == TIPV4)
365 tkey->val = ntohl(tkey->val);
366
367 if (len == 1) {
368 res = pack_key8(retain, sel, tkey);
369 goto done;
370 }
371 if (len == 2) {
372 res = pack_key16(retain, sel, tkey);
373 goto done;
374 }
375 if (len == 4) {
376 res = pack_key32(retain, sel, tkey);
377 goto done;
378 }
379
380 return -1;
381 done:
382 if (pedit_debug)
383 printf("parse_cmd done argc %d %s offset %d length %d\n",
384 argc, *argv, tkey->off, len);
385 *argc_p = argc;
386 *argv_p = argv;
387 return res;
388
389 }
390
391 int parse_offset(int *argc_p, char ***argv_p, struct m_pedit_sel *sel,
392 struct m_pedit_key *tkey)
393 {
394 int off;
395 __u32 len, retain;
396 int argc = *argc_p;
397 char **argv = *argv_p;
398 int res = -1;
399
400 if (argc <= 0)
401 return -1;
402
403 if (get_integer(&off, *argv, 0))
404 return -1;
405 tkey->off = off;
406
407 argc--;
408 argv++;
409
410 if (argc <= 0)
411 return -1;
412
413 if (matches(*argv, "u32") == 0) {
414 len = 4;
415 retain = 0xFFFFFFFF;
416 goto done;
417 }
418 if (matches(*argv, "u16") == 0) {
419 len = 2;
420 retain = 0xffff;
421 goto done;
422 }
423 if (matches(*argv, "u8") == 0) {
424 len = 1;
425 retain = 0xff;
426 goto done;
427 }
428
429 return -1;
430
431 done:
432
433 NEXT_ARG();
434
435 /* [at <someval> offmask <maskval> shift <shiftval>] */
436 if (matches(*argv, "at") == 0) {
437
438 __u32 atv = 0, offmask = 0x0, shift = 0;
439
440 NEXT_ARG();
441 if (get_u32(&atv, *argv, 0))
442 return -1;
443 tkey->at = atv;
444
445 NEXT_ARG();
446
447 if (get_u32(&offmask, *argv, 16))
448 return -1;
449 tkey->offmask = offmask;
450
451 NEXT_ARG();
452
453 if (get_u32(&shift, *argv, 0))
454 return -1;
455 tkey->shift = shift;
456
457 NEXT_ARG();
458 }
459
460 res = parse_cmd(&argc, &argv, len, TU32, retain, sel, tkey);
461
462 *argc_p = argc;
463 *argv_p = argv;
464 return res;
465 }
466
467 static int parse_munge(int *argc_p, char ***argv_p, struct m_pedit_sel *sel)
468 {
469 struct m_pedit_key tkey = {};
470 int argc = *argc_p;
471 char **argv = *argv_p;
472 int res = -1;
473
474 if (argc <= 0)
475 return -1;
476
477 if (matches(*argv, "offset") == 0) {
478 NEXT_ARG();
479 res = parse_offset(&argc, &argv, sel, &tkey);
480 goto done;
481 } else {
482 char k[16];
483 struct m_pedit_util *p = NULL;
484
485 strncpy(k, *argv, sizeof(k) - 1);
486
487 if (argc > 0) {
488 p = get_pedit_kind(k);
489 if (p == NULL)
490 goto bad_val;
491 NEXT_ARG();
492 res = p->parse_peopt(&argc, &argv, sel, &tkey);
493 if (res < 0) {
494 fprintf(stderr, "bad pedit parsing\n");
495 goto bad_val;
496 }
497 goto done;
498 }
499 }
500
501 bad_val:
502 return -1;
503
504 done:
505
506 *argc_p = argc;
507 *argv_p = argv;
508 return res;
509 }
510
511 static int pedit_keys_ex_getattr(struct rtattr *attr,
512 struct m_pedit_key_ex *keys_ex, int n)
513 {
514 struct rtattr *i;
515 int rem = RTA_PAYLOAD(attr);
516 struct rtattr *tb[TCA_PEDIT_KEY_EX_MAX + 1];
517 struct m_pedit_key_ex *k = keys_ex;
518
519 for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
520 if (!n)
521 return -1;
522
523 if (i->rta_type != TCA_PEDIT_KEY_EX)
524 return -1;
525
526 parse_rtattr_nested(tb, TCA_PEDIT_KEY_EX_MAX, i);
527
528 k->htype = rta_getattr_u16(tb[TCA_PEDIT_KEY_EX_HTYPE]);
529 k->cmd = rta_getattr_u16(tb[TCA_PEDIT_KEY_EX_CMD]);
530
531 k++;
532 n--;
533 }
534
535 return !!n;
536 }
537
538 static int pedit_keys_ex_addattr(struct m_pedit_sel *sel, struct nlmsghdr *n)
539 {
540 struct m_pedit_key_ex *k = sel->keys_ex;
541 struct rtattr *keys_start;
542 int i;
543
544 if (!sel->extended)
545 return 0;
546
547 keys_start = addattr_nest(n, MAX_MSG, TCA_PEDIT_KEYS_EX | NLA_F_NESTED);
548
549 for (i = 0; i < sel->sel.nkeys; i++) {
550 struct rtattr *key_start;
551
552 key_start = addattr_nest(n, MAX_MSG,
553 TCA_PEDIT_KEY_EX | NLA_F_NESTED);
554
555 if (addattr16(n, MAX_MSG, TCA_PEDIT_KEY_EX_HTYPE, k->htype) ||
556 addattr16(n, MAX_MSG, TCA_PEDIT_KEY_EX_CMD, k->cmd)) {
557 return -1;
558 }
559
560 addattr_nest_end(n, key_start);
561
562 k++;
563 }
564
565 addattr_nest_end(n, keys_start);
566
567 return 0;
568 }
569
570 int parse_pedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
571 struct nlmsghdr *n)
572 {
573 struct m_pedit_sel sel = {};
574
575 int argc = *argc_p;
576 char **argv = *argv_p;
577 int ok = 0, iok = 0;
578 struct rtattr *tail;
579
580 while (argc > 0) {
581 if (pedit_debug > 1)
582 fprintf(stderr, "while pedit (%d:%s)\n", argc, *argv);
583 if (matches(*argv, "pedit") == 0) {
584 NEXT_ARG();
585 ok++;
586
587 if (matches(*argv, "ex") == 0) {
588 if (ok > 1) {
589 fprintf(stderr,
590 "'ex' must be before first 'munge'\n");
591 explain();
592 return -1;
593 }
594 sel.extended = true;
595 NEXT_ARG();
596 }
597
598 continue;
599 } else if (matches(*argv, "help") == 0) {
600 usage();
601 } else if (matches(*argv, "munge") == 0) {
602 if (!ok) {
603 fprintf(stderr, "Bad pedit construct (%s)\n",
604 *argv);
605 explain();
606 return -1;
607 }
608 NEXT_ARG();
609
610 if (parse_munge(&argc, &argv, &sel)) {
611 fprintf(stderr, "Bad pedit construct (%s)\n",
612 *argv);
613 explain();
614 return -1;
615 }
616 ok++;
617 } else {
618 break;
619 }
620
621 }
622
623 if (!ok) {
624 explain();
625 return -1;
626 }
627
628 if (argc && !action_a2n(*argv, &sel.sel.action, false))
629 NEXT_ARG();
630
631 if (argc) {
632 if (matches(*argv, "index") == 0) {
633 NEXT_ARG();
634 if (get_u32(&sel.sel.index, *argv, 10)) {
635 fprintf(stderr, "Pedit: Illegal \"index\"\n");
636 return -1;
637 }
638 argc--;
639 argv++;
640 iok++;
641 }
642 }
643
644 tail = NLMSG_TAIL(n);
645 addattr_l(n, MAX_MSG, tca_id, NULL, 0);
646 if (!sel.extended) {
647 addattr_l(n, MAX_MSG, TCA_PEDIT_PARMS, &sel,
648 sizeof(sel.sel) +
649 sel.sel.nkeys * sizeof(struct tc_pedit_key));
650 } else {
651 addattr_l(n, MAX_MSG, TCA_PEDIT_PARMS_EX, &sel,
652 sizeof(sel.sel) +
653 sel.sel.nkeys * sizeof(struct tc_pedit_key));
654
655 pedit_keys_ex_addattr(&sel, n);
656 }
657
658 tail->rta_len = (void *)NLMSG_TAIL(n) - (void *)tail;
659
660 *argc_p = argc;
661 *argv_p = argv;
662 return 0;
663 }
664
665 const char *pedit_htype_str[] = {
666 [TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK] = "",
667 [TCA_PEDIT_KEY_EX_HDR_TYPE_ETH] = "eth",
668 [TCA_PEDIT_KEY_EX_HDR_TYPE_IP4] = "ipv4",
669 [TCA_PEDIT_KEY_EX_HDR_TYPE_IP6] = "ipv6",
670 [TCA_PEDIT_KEY_EX_HDR_TYPE_TCP] = "tcp",
671 [TCA_PEDIT_KEY_EX_HDR_TYPE_UDP] = "udp",
672 };
673
674 static void print_pedit_location(FILE *f,
675 enum pedit_header_type htype, __u32 off)
676 {
677 if (htype == TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK) {
678 fprintf(f, "%d", (unsigned int)off);
679 return;
680 }
681
682 if (htype < ARRAY_SIZE(pedit_htype_str))
683 fprintf(f, "%s", pedit_htype_str[htype]);
684 else
685 fprintf(f, "unknown(%d)", htype);
686
687 fprintf(f, "%c%d", (int)off >= 0 ? '+' : '-', abs((int)off));
688 }
689
690 int print_pedit(struct action_util *au, FILE *f, struct rtattr *arg)
691 {
692 struct tc_pedit_sel *sel;
693 struct rtattr *tb[TCA_PEDIT_MAX + 1];
694 struct m_pedit_key_ex *keys_ex = NULL;
695
696 if (arg == NULL)
697 return -1;
698
699 parse_rtattr_nested(tb, TCA_PEDIT_MAX, arg);
700
701 if (!tb[TCA_PEDIT_PARMS] && !tb[TCA_PEDIT_PARMS_EX]) {
702 fprintf(f, "[NULL pedit parameters]");
703 return -1;
704 }
705
706 if (tb[TCA_PEDIT_PARMS]) {
707 sel = RTA_DATA(tb[TCA_PEDIT_PARMS]);
708 } else {
709 int err;
710
711 sel = RTA_DATA(tb[TCA_PEDIT_PARMS_EX]);
712
713 if (!tb[TCA_PEDIT_KEYS_EX]) {
714 fprintf(f, "Netlink error\n");
715 return -1;
716 }
717
718 keys_ex = calloc(sel->nkeys, sizeof(*keys_ex));
719 if (!keys_ex) {
720 fprintf(f, "Out of memory\n");
721 return -1;
722 }
723
724 err = pedit_keys_ex_getattr(tb[TCA_PEDIT_KEYS_EX], keys_ex,
725 sel->nkeys);
726 if (err) {
727 fprintf(f, "Netlink error\n");
728
729 free(keys_ex);
730 return -1;
731 }
732 }
733
734 fprintf(f, " pedit action %s keys %d\n ",
735 action_n2a(sel->action), sel->nkeys);
736 fprintf(f, "\t index %u ref %d bind %d", sel->index, sel->refcnt,
737 sel->bindcnt);
738
739 if (show_stats) {
740 if (tb[TCA_PEDIT_TM]) {
741 struct tcf_t *tm = RTA_DATA(tb[TCA_PEDIT_TM]);
742
743 print_tm(f, tm);
744 }
745 }
746 if (sel->nkeys) {
747 int i;
748 struct tc_pedit_key *key = sel->keys;
749 struct m_pedit_key_ex *key_ex = keys_ex;
750
751 for (i = 0; i < sel->nkeys; i++, key++) {
752 enum pedit_header_type htype =
753 TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK;
754 enum pedit_cmd cmd = TCA_PEDIT_KEY_EX_CMD_SET;
755
756 if (keys_ex) {
757 htype = key_ex->htype;
758 cmd = key_ex->cmd;
759
760 key_ex++;
761 }
762
763 fprintf(f, "\n\t key #%d", i);
764
765 fprintf(f, " at ");
766
767 print_pedit_location(f, htype, key->off);
768
769 fprintf(f, ": %s %08x mask %08x",
770 cmd ? "add" : "val",
771 (unsigned int)ntohl(key->val),
772 (unsigned int)ntohl(key->mask));
773 }
774 } else {
775 fprintf(f, "\npedit %x keys %d is not LEGIT", sel->index,
776 sel->nkeys);
777 }
778
779 fprintf(f, "\n ");
780
781 free(keys_ex);
782 return 0;
783 }
784
785 int pedit_print_xstats(struct action_util *au, FILE *f, struct rtattr *xstats)
786 {
787 return 0;
788 }
789
790 struct action_util pedit_action_util = {
791 .id = "pedit",
792 .parse_aopt = parse_pedit,
793 .print_aopt = print_pedit,
794 };