diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-06-21 13:47:29 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-06-21 13:47:29 +0000 |
commit | 4abfdca336163631193aa69415c6a157c1b47abc (patch) | |
tree | d2ac4901eeb650b55a040adf8b4dfd62c701a4d6 | |
parent | f88789403999d2e9709fb21bb3f78f3375511dfc (diff) | |
parent | 4e76b3450f1d74947ee62eb7300409d7888777cf (diff) | |
download | platform_external_iproute2-4abfdca336163631193aa69415c6a157c1b47abc.tar.gz platform_external_iproute2-4abfdca336163631193aa69415c6a157c1b47abc.tar.bz2 platform_external_iproute2-4abfdca336163631193aa69415c6a157c1b47abc.zip |
Merge "UPSTREAM: ip-xfrm: Add support for OUTPUT_MARK"
-rw-r--r-- | ip/ipxfrm.c | 17 | ||||
-rw-r--r-- | ip/xfrm_state.c | 9 | ||||
-rw-r--r-- | man/man8/ip-xfrm.8 | 11 |
3 files changed, 36 insertions, 1 deletions
diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c index 12c2f721..17ab4abe 100644 --- a/ip/ipxfrm.c +++ b/ip/ipxfrm.c @@ -637,6 +637,13 @@ static void xfrm_tmpl_print(struct xfrm_user_tmpl *tmpls, int len, } } +static void xfrm_output_mark_print(struct rtattr *tb[], FILE *fp) +{ + __u32 output_mark = rta_getattr_u32(tb[XFRMA_OUTPUT_MARK]); + + fprintf(fp, "output-mark 0x%x", output_mark); +} + int xfrm_parse_mark(struct xfrm_mark *mark, int *argcp, char ***argvp) { int argc = *argcp; @@ -677,7 +684,15 @@ void xfrm_xfrma_print(struct rtattr *tb[], __u16 family, struct rtattr *rta = tb[XFRMA_MARK]; struct xfrm_mark *m = RTA_DATA(rta); - fprintf(fp, "\tmark %#x/%#x", m->v, m->m); + fprintf(fp, "\tmark %#x/%#x ", m->v, m->m); + + if (tb[XFRMA_OUTPUT_MARK]) + xfrm_output_mark_print(tb, fp); + fprintf(fp, "%s", _SL_); + } else if (tb[XFRMA_OUTPUT_MARK]) { + fprintf(fp, "\t"); + + xfrm_output_mark_print(tb, fp); fprintf(fp, "%s", _SL_); } diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c index ba5d6639..d4cf94da 100644 --- a/ip/xfrm_state.c +++ b/ip/xfrm_state.c @@ -61,6 +61,7 @@ static void usage(void) fprintf(stderr, " [ flag FLAG-LIST ] [ sel SELECTOR ] [ LIMIT-LIST ] [ encap ENCAP ]\n"); fprintf(stderr, " [ coa ADDR[/PLEN] ] [ ctx CTX ] [ extra-flag EXTRA-FLAG-LIST ]\n"); fprintf(stderr, " [ offload [dev DEV] dir DIR ]\n"); + fprintf(stderr, " [ output-mark OUTPUT-MARK ]\n"); fprintf(stderr, "Usage: ip xfrm state allocspi ID [ mode MODE ] [ mark MARK [ mask MASK ] ]\n"); fprintf(stderr, " [ reqid REQID ] [ seq SEQ ] [ min SPI max SPI ]\n"); fprintf(stderr, "Usage: ip xfrm state { delete | get } ID [ mark MARK [ mask MASK ] ]\n"); @@ -322,6 +323,7 @@ static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv) struct xfrm_user_sec_ctx sctx; char str[CTX_BUF_SIZE]; } ctx = {}; + __u32 output_mark = 0; while (argc > 0) { if (strcmp(*argv, "mode") == 0) { @@ -437,6 +439,10 @@ static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv) invarg("value after \"offload dir\" is invalid", *argv); is_offload = false; } + } else if (strcmp(*argv, "output-mark") == 0) { + NEXT_ARG(); + if (get_u32(&output_mark, *argv, 0)) + invarg("value after \"output-mark\" is invalid", *argv); } else { /* try to assume ALGO */ int type = xfrm_algotype_getbyname(*argv); @@ -720,6 +726,9 @@ static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv) } } + if (output_mark) + addattr32(&req.n, sizeof(req.buf), XFRMA_OUTPUT_MARK, output_mark); + if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) exit(1); diff --git a/man/man8/ip-xfrm.8 b/man/man8/ip-xfrm.8 index a0bbef55..425be33d 100644 --- a/man/man8/ip-xfrm.8 +++ b/man/man8/ip-xfrm.8 @@ -59,6 +59,8 @@ ip-xfrm \- transform configuration .IR CTX " ]" .RB "[ " extra-flag .IR EXTRA-FLAG-LIST " ]" +.RB "[ " output-mark +.IR OUTPUT-MARK " ]" .ti -8 .B "ip xfrm state allocspi" @@ -536,6 +538,15 @@ encapsulates packets with protocol .RI "using source port " SPORT ", destination port " DPORT .RI ", and original address " OADDR "." +.TP +.I MARK +used to match xfrm policies and states + +.TP +.I OUTPUT-MARK +used to set the output mark to influence the routing +of the packets emitted by the state + .sp .PP .TS |