Skip to content

Commit 7e5fab5

Browse files
committed
patch release: v6
Signed-off-by: Christian Hopps <[email protected]>
1 parent f2cd7a8 commit 7e5fab5

File tree

58 files changed

+16275
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+16275
-2
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,11 @@ flame-%.svg: $(PERFPFX)/perf-%.fdata
162162
# Making and sending patches
163163
#
164164
#
165-
# git format-patch -v2 --subject-prefix="RFC ipsec-next" -o ../patches/v2/ upstream/master..HEAD
165+
# V=6; git format-patch -v$V --subject-prefix="RFC ipsec-next" -o ../patches/v$V/ upstream/master..origin/iptfs
166+
#
167+
# for f in ../patches/v$V/v$V-*; do echo ====$f====; scripts/checkpatch.pl --ignore=AVOID_BUG $f; done
168+
#
166169
# git send-email --cc='Steffen Klassert <[email protected]>' \
167170
168-
# --cc='[email protected]' ../patches/v2 \
171+
# --cc='[email protected]' ../patches/v$V \
169172
#
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
From: Christian Hopps <[email protected]>
2+
Subject: [PATCH iproute-next v1 0/2] Add support for xfrm state direction attribute
3+
4+
Summary of Changes:
5+
6+
This patchset adds support for setting the new xfrm state direction
7+
attribute.
8+
9+
The change also takes into account the existing "offload" direction
10+
atttribute. If the user is already setting the direction when
11+
enabling offload then that direciton value is used, and the general
12+
"dir in|out" need not additionally be specified.
13+
14+
This work was started based on an earlier patch from
15+
"Antony Antony" <[email protected]>
16+
17+
Patchset Changes:
18+
19+
4 files changed, 57 insertions(+), 16 deletions(-)
20+
include/uapi/linux/xfrm.h | 6 ++++++
21+
ip/ipxfrm.c | 12 ++++++++++++
22+
ip/xfrm_state.c | 49 +++++++++++++++++++++++++++++++----------------
23+
man/man8/ip-xfrm.8 | 6 ++++++
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
From 3007d6acf2a961427fc524a33413abec4ce880c2 Mon Sep 17 00:00:00 2001
2+
From: Christian Hopps <[email protected]>
3+
Date: Mon, 20 May 2024 10:46:19 -0400
4+
Subject: [PATCH iproute-next v1 1/2] xfrm: add SA direction attribute
5+
6+
Add support for new SA direction netlink attribute.
7+
8+
Co-developed-by: Antony Antony <[email protected]>
9+
Co-developed-by: Christian Hopps <[email protected]>
10+
Signed-off-by: Christian Hopps <[email protected]>
11+
---
12+
include/uapi/linux/xfrm.h | 6 +++++
13+
ip/ipxfrm.c | 12 ++++++++++
14+
ip/xfrm_state.c | 49 ++++++++++++++++++++++++++-------------
15+
3 files changed, 51 insertions(+), 16 deletions(-)
16+
17+
diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h
18+
index 43efaeca..dccfd437 100644
19+
--- a/include/uapi/linux/xfrm.h
20+
+++ b/include/uapi/linux/xfrm.h
21+
@@ -141,6 +141,11 @@ enum {
22+
XFRM_POLICY_MAX = 3
23+
};
24+
25+
+enum xfrm_sa_dir {
26+
+ XFRM_SA_DIR_IN = 1,
27+
+ XFRM_SA_DIR_OUT = 2
28+
+};
29+
+
30+
enum {
31+
XFRM_SHARE_ANY, /* No limitations */
32+
XFRM_SHARE_SESSION, /* For this session only */
33+
@@ -315,6 +320,7 @@ enum xfrm_attr_type_t {
34+
XFRMA_SET_MARK_MASK, /* __u32 */
35+
XFRMA_IF_ID, /* __u32 */
36+
XFRMA_MTIMER_THRESH, /* __u32 in seconds for input SA */
37+
+ XFRMA_SA_DIR, /* __u8 */
38+
__XFRMA_MAX
39+
40+
#define XFRMA_OUTPUT_MARK XFRMA_SET_MARK /* Compatibility */
41+
diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c
42+
index b78c712d..90d25aac 100644
43+
--- a/ip/ipxfrm.c
44+
+++ b/ip/ipxfrm.c
45+
@@ -904,6 +904,18 @@ void xfrm_xfrma_print(struct rtattr *tb[], __u16 family, FILE *fp,
46+
fprintf(fp, "tfcpad %u", tfcpad);
47+
fprintf(fp, "%s", _SL_);
48+
}
49+
+ if (tb[XFRMA_SA_DIR]) {
50+
+ __u8 dir = rta_getattr_u8(tb[XFRMA_SA_DIR]);
51+
+
52+
+ fprintf(fp, "\tdir ");
53+
+ if (dir == XFRM_SA_DIR_IN)
54+
+ fprintf(fp, "in");
55+
+ else if (dir == XFRM_SA_DIR_OUT)
56+
+ fprintf(fp, "out");
57+
+ else
58+
+ fprintf(fp, "other (%d)", dir);
59+
+ fprintf(fp, "%s", _SL_);
60+
+ }
61+
}
62+
63+
static int xfrm_selector_iszero(struct xfrm_selector *s)
64+
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
65+
index 9be65b2f..fbb1f913 100644
66+
--- a/ip/xfrm_state.c
67+
+++ b/ip/xfrm_state.c
68+
@@ -40,7 +40,7 @@ static void usage(void)
69+
{
70+
fprintf(stderr,
71+
"Usage: ip xfrm state { add | update } ID [ ALGO-LIST ] [ mode MODE ]\n"
72+
- " [ mark MARK [ mask MASK ] ] [ reqid REQID ] [ seq SEQ ]\n"
73+
+ " [ mark MARK [ mask MASK ] ] [ reqid REQID ] [ dir DIR ] [ seq SEQ ]\n"
74+
" [ replay-window SIZE ] [ replay-seq SEQ ] [ replay-oseq SEQ ]\n"
75+
" [ replay-seq-hi SEQ ] [ replay-oseq-hi SEQ ]\n"
76+
" [ flag FLAG-LIST ] [ sel SELECTOR ] [ LIMIT-LIST ] [ encap ENCAP ]\n"
77+
@@ -49,7 +49,7 @@ static void usage(void)
78+
" [ output-mark OUTPUT-MARK [ mask MASK ] ]\n"
79+
" [ if_id IF_ID ] [ tfcpad LENGTH ]\n"
80+
"Usage: ip xfrm state allocspi ID [ mode MODE ] [ mark MARK [ mask MASK ] ]\n"
81+
- " [ reqid REQID ] [ seq SEQ ] [ min SPI max SPI ]\n"
82+
+ " [ reqid REQID ] [ dir DIR ] [ seq SEQ ] [ min SPI max SPI ]\n"
83+
"Usage: ip xfrm state { delete | get } ID [ mark MARK [ mask MASK ] ]\n"
84+
"Usage: ip xfrm state deleteall [ ID ] [ mode MODE ] [ reqid REQID ]\n"
85+
" [ flag FLAG-LIST ]\n"
86+
@@ -251,22 +251,20 @@ static int xfrm_state_extra_flag_parse(__u32 *extra_flags, int *argcp, char ***a
87+
return 0;
88+
}
89+
90+
-static bool xfrm_offload_dir_parse(__u8 *dir, int *argcp, char ***argvp)
91+
+static void xfrm_dir_parse(__u8 *dir, int *argcp, char ***argvp)
92+
{
93+
int argc = *argcp;
94+
char **argv = *argvp;
95+
96+
if (strcmp(*argv, "in") == 0)
97+
- *dir = XFRM_OFFLOAD_INBOUND;
98+
+ *dir = XFRM_SA_DIR_IN;
99+
else if (strcmp(*argv, "out") == 0)
100+
- *dir = 0;
101+
+ *dir = XFRM_SA_DIR_OUT;
102+
else
103+
- return false;
104+
+ invarg("DIR value is not \"in\" or \"out\"", *argv);
105+
106+
*argcp = argc;
107+
*argvp = argv;
108+
-
109+
- return true;
110+
}
111+
112+
static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv)
113+
@@ -429,13 +427,8 @@ static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv)
114+
115+
NEXT_ARG();
116+
if (strcmp(*argv, "dir") == 0) {
117+
- bool is_dir;
118+
-
119+
NEXT_ARG();
120+
- is_dir = xfrm_offload_dir_parse(&dir, &argc,
121+
- &argv);
122+
- if (!is_dir)
123+
- invarg("DIR value is invalid", *argv);
124+
+ xfrm_dir_parse(&dir, &argc, &argv);
125+
} else
126+
invarg("Missing DIR keyword", *argv);
127+
is_offload = true;
128+
@@ -462,6 +455,9 @@ static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv)
129+
NEXT_ARG();
130+
if (get_u32(&tfcpad, *argv, 0))
131+
invarg("value after \"tfcpad\" is invalid", *argv);
132+
+ } else if (strcmp(*argv, "dir") == 0) {
133+
+ NEXT_ARG();
134+
+ xfrm_dir_parse(&dir, &argc, &argv);
135+
} else {
136+
/* try to assume ALGO */
137+
int type = xfrm_algotype_getbyname(*argv);
138+
@@ -587,7 +583,7 @@ static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv)
139+
}
140+
141+
if (req.xsinfo.flags & XFRM_STATE_ESN &&
142+
- replay_window == 0) {
143+
+ replay_window == 0 && dir != XFRM_SA_DIR_OUT ) {
144+
fprintf(stderr, "Error: esn flag set without replay-window.\n");
145+
exit(-1);
146+
}
147+
@@ -601,7 +597,7 @@ static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv)
148+
149+
if (is_offload) {
150+
xuo.ifindex = ifindex;
151+
- xuo.flags = dir;
152+
+ xuo.flags = dir == XFRM_SA_DIR_IN ? XFRM_OFFLOAD_INBOUND : 0;
153+
if (is_packet_offload)
154+
xuo.flags |= XFRM_OFFLOAD_PACKET;
155+
addattr_l(&req.n, sizeof(req.buf), XFRMA_OFFLOAD_DEV, &xuo,
156+
@@ -763,6 +759,14 @@ static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv)
157+
if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
158+
exit(1);
159+
160+
+ if (dir) {
161+
+ int r = addattr8(&req.n, sizeof(req.buf), XFRMA_SA_DIR, dir);
162+
+ if (r < 0) {
163+
+ fprintf(stderr, "XFRMA_SA_DIR failed\n");
164+
+ exit(1);
165+
+ }
166+
+ }
167+
+
168+
if (req.xsinfo.family == AF_UNSPEC)
169+
req.xsinfo.family = AF_INET;
170+
171+
@@ -792,6 +796,7 @@ static int xfrm_state_allocspi(int argc, char **argv)
172+
char *maxp = NULL;
173+
struct xfrm_mark mark = {0, 0};
174+
struct nlmsghdr *answer;
175+
+ __u8 dir = 0;
176+
177+
while (argc > 0) {
178+
if (strcmp(*argv, "mode") == 0) {
179+
@@ -823,6 +828,9 @@ static int xfrm_state_allocspi(int argc, char **argv)
180+
181+
if (get_u32(&req.xspi.max, *argv, 0))
182+
invarg("value after \"max\" is invalid", *argv);
183+
+ } else if (strcmp(*argv, "dir") == 0) {
184+
+ NEXT_ARG();
185+
+ xfrm_dir_parse(&dir, &argc, &argv);
186+
} else {
187+
/* try to assume ID */
188+
if (idp)
189+
@@ -875,6 +883,15 @@ static int xfrm_state_allocspi(int argc, char **argv)
190+
req.xspi.max = 0xffff;
191+
}
192+
193+
+ if (dir) {
194+
+ int r = addattr8(&req.n, sizeof(req.buf), XFRMA_SA_DIR, dir);
195+
+
196+
+ if (r < 0) {
197+
+ fprintf(stderr, "XFRMA_SA_DIR failed\n");
198+
+ exit(1);
199+
+ }
200+
+ }
201+
+
202+
if (mark.m & mark.v) {
203+
int r = addattr_l(&req.n, sizeof(req.buf), XFRMA_MARK,
204+
(void *)&mark, sizeof(mark));
205+
--
206+
2.45.1
207+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
From af2c9037e167d3cb2ade3b296aa9cf3b388938d0 Mon Sep 17 00:00:00 2001
2+
From: Christian Hopps <[email protected]>
3+
Date: Wed, 22 May 2024 06:11:55 -0400
4+
Subject: [PATCH iproute-next v1 2/2] xfrm: document new SA direction option
5+
6+
Signed-off-by: Christian Hopps <[email protected]>
7+
---
8+
man/man8/ip-xfrm.8 | 6 ++++++
9+
1 file changed, 6 insertions(+)
10+
11+
diff --git a/man/man8/ip-xfrm.8 b/man/man8/ip-xfrm.8
12+
index 6dc73d23..960779dd 100644
13+
--- a/man/man8/ip-xfrm.8
14+
+++ b/man/man8/ip-xfrm.8
15+
@@ -36,6 +36,8 @@ ip-xfrm \- transform configuration
16+
.IR MASK " ] ]"
17+
.RB "[ " reqid
18+
.IR REQID " ]"
19+
+.RB "[ " dir
20+
+.IR SA-DIR " ]"
21+
.RB "[ " seq
22+
.IR SEQ " ]"
23+
.RB "[ " replay-window
24+
@@ -165,6 +167,10 @@ ip-xfrm \- transform configuration
25+
.IR MODE " := "
26+
.BR transport " | " tunnel " | " beet " | " ro " | " in_trigger
27+
28+
+.ti -8
29+
+.IR SA-DIR " := "
30+
+.BR in " | " out
31+
+
32+
.ti -8
33+
.IR FLAG-LIST " := [ " FLAG-LIST " ] " FLAG
34+
35+
--
36+
2.45.1
37+

0 commit comments

Comments
 (0)