Skip to content

Commit 4c145dc

Browse files
Florian Westphalklassert
authored andcommitted
xfrm: make xfrm modes builtin
after previous changes, xfrm_mode contains no function pointers anymore and all modules defining such struct contain no code except an init/exit functions to register the xfrm_mode struct with the xfrm core. Just place the xfrm modes core and remove the modules, the run-time xfrm_mode register/unregister functionality is removed. Before: text data bss dec filename 7523 200 2364 10087 net/xfrm/xfrm_input.o 40003 628 440 41071 net/xfrm/xfrm_state.o 15730338 6937080 4046908 26714326 vmlinux 7389 200 2364 9953 net/xfrm/xfrm_input.o 40574 656 440 41670 net/xfrm/xfrm_state.o 15730084 6937068 4046908 26714060 vmlinux The xfrm*_mode_{transport,tunnel,beet} modules are gone. v2: replace CONFIG_INET6_XFRM_MODE_* IS_ENABLED guards with CONFIG_IPV6 ones rather than removing them. Signed-off-by: Florian Westphal <fw@strlen.de> Reviewed-by: Sabrina Dubroca <sd@queasysnail.net> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
1 parent 733a5fa commit 4c145dc

20 files changed

+81
-493
lines changed

include/net/xfrm.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ struct xfrm_state {
234234
/* Reference to data common to all the instances of this
235235
* transformer. */
236236
const struct xfrm_type *type;
237-
struct xfrm_mode *inner_mode;
238-
struct xfrm_mode *inner_mode_iaf;
239-
struct xfrm_mode *outer_mode;
237+
const struct xfrm_mode *inner_mode;
238+
const struct xfrm_mode *inner_mode_iaf;
239+
const struct xfrm_mode *outer_mode;
240240

241241
const struct xfrm_type_offload *type_offload;
242242

@@ -347,7 +347,6 @@ struct xfrm_state_afinfo {
347347
struct module *owner;
348348
const struct xfrm_type *type_map[IPPROTO_MAX];
349349
const struct xfrm_type_offload *type_offload_map[IPPROTO_MAX];
350-
struct xfrm_mode *mode_map[XFRM_MODE_MAX];
351350

352351
int (*init_flags)(struct xfrm_state *x);
353352
void (*init_tempsel)(struct xfrm_selector *sel,
@@ -423,7 +422,6 @@ int xfrm_register_type_offload(const struct xfrm_type_offload *type, unsigned sh
423422
int xfrm_unregister_type_offload(const struct xfrm_type_offload *type, unsigned short family);
424423

425424
struct xfrm_mode {
426-
struct module *owner;
427425
u8 encap;
428426
u8 family;
429427
u8 flags;
@@ -434,9 +432,6 @@ enum {
434432
XFRM_MODE_FLAG_TUNNEL = 1,
435433
};
436434

437-
int xfrm_register_mode(struct xfrm_mode *mode);
438-
void xfrm_unregister_mode(struct xfrm_mode *mode);
439-
440435
static inline int xfrm_af2proto(unsigned int family)
441436
{
442437
switch(family) {
@@ -449,7 +444,7 @@ static inline int xfrm_af2proto(unsigned int family)
449444
}
450445
}
451446

452-
static inline struct xfrm_mode *xfrm_ip2inner_mode(struct xfrm_state *x, int ipproto)
447+
static inline const struct xfrm_mode *xfrm_ip2inner_mode(struct xfrm_state *x, int ipproto)
453448
{
454449
if ((ipproto == IPPROTO_IPIP && x->props.family == AF_INET) ||
455450
(ipproto == IPPROTO_IPV6 && x->props.family == AF_INET6))

net/ipv4/Kconfig

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ config NET_IPVTI
304304
tristate "Virtual (secure) IP: tunneling"
305305
select INET_TUNNEL
306306
select NET_IP_TUNNEL
307-
depends on INET_XFRM_MODE_TUNNEL
307+
select XFRM
308308
---help---
309309
Tunneling means encapsulating data of one protocol type within
310310
another protocol and sending it over a channel that understands the
@@ -396,33 +396,6 @@ config INET_TUNNEL
396396
tristate
397397
default n
398398

399-
config INET_XFRM_MODE_TRANSPORT
400-
tristate "IP: IPsec transport mode"
401-
default y
402-
select XFRM
403-
---help---
404-
Support for IPsec transport mode.
405-
406-
If unsure, say Y.
407-
408-
config INET_XFRM_MODE_TUNNEL
409-
tristate "IP: IPsec tunnel mode"
410-
default y
411-
select XFRM
412-
---help---
413-
Support for IPsec tunnel mode.
414-
415-
If unsure, say Y.
416-
417-
config INET_XFRM_MODE_BEET
418-
tristate "IP: IPsec BEET mode"
419-
default y
420-
select XFRM
421-
---help---
422-
Support for IPsec BEET mode.
423-
424-
If unsure, say Y.
425-
426399
config INET_DIAG
427400
tristate "INET: socket monitoring interface"
428401
default y

net/ipv4/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ obj-$(CONFIG_INET_ESP) += esp4.o
3737
obj-$(CONFIG_INET_ESP_OFFLOAD) += esp4_offload.o
3838
obj-$(CONFIG_INET_IPCOMP) += ipcomp.o
3939
obj-$(CONFIG_INET_XFRM_TUNNEL) += xfrm4_tunnel.o
40-
obj-$(CONFIG_INET_XFRM_MODE_BEET) += xfrm4_mode_beet.o
4140
obj-$(CONFIG_INET_TUNNEL) += tunnel4.o
42-
obj-$(CONFIG_INET_XFRM_MODE_TRANSPORT) += xfrm4_mode_transport.o
43-
obj-$(CONFIG_INET_XFRM_MODE_TUNNEL) += xfrm4_mode_tunnel.o
4441
obj-$(CONFIG_IP_PNP) += ipconfig.o
4542
obj-$(CONFIG_NETFILTER) += netfilter.o netfilter/
4643
obj-$(CONFIG_INET_DIAG) += inet_diag.o

net/ipv4/ip_vti.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static int vti_rcv_cb(struct sk_buff *skb, int err)
107107
struct net_device *dev;
108108
struct pcpu_sw_netstats *tstats;
109109
struct xfrm_state *x;
110-
struct xfrm_mode *inner_mode;
110+
const struct xfrm_mode *inner_mode;
111111
struct ip_tunnel *tunnel = XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4;
112112
u32 orig_mark = skb->mark;
113113
int ret;

net/ipv4/xfrm4_mode_beet.c

Lines changed: 0 additions & 41 deletions
This file was deleted.

net/ipv4/xfrm4_mode_transport.c

Lines changed: 0 additions & 36 deletions
This file was deleted.

net/ipv4/xfrm4_mode_tunnel.c

Lines changed: 0 additions & 38 deletions
This file was deleted.

net/ipv6/Kconfig

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -135,44 +135,11 @@ config INET6_TUNNEL
135135
tristate
136136
default n
137137

138-
config INET6_XFRM_MODE_TRANSPORT
139-
tristate "IPv6: IPsec transport mode"
140-
default IPV6
141-
select XFRM
142-
---help---
143-
Support for IPsec transport mode.
144-
145-
If unsure, say Y.
146-
147-
config INET6_XFRM_MODE_TUNNEL
148-
tristate "IPv6: IPsec tunnel mode"
149-
default IPV6
150-
select XFRM
151-
---help---
152-
Support for IPsec tunnel mode.
153-
154-
If unsure, say Y.
155-
156-
config INET6_XFRM_MODE_BEET
157-
tristate "IPv6: IPsec BEET mode"
158-
default IPV6
159-
select XFRM
160-
---help---
161-
Support for IPsec BEET mode.
162-
163-
If unsure, say Y.
164-
165-
config INET6_XFRM_MODE_ROUTEOPTIMIZATION
166-
tristate "IPv6: MIPv6 route optimization mode"
167-
select XFRM
168-
---help---
169-
Support for MIPv6 route optimization mode.
170-
171138
config IPV6_VTI
172139
tristate "Virtual (secure) IPv6: tunneling"
173140
select IPV6_TUNNEL
174141
select NET_IP_TUNNEL
175-
depends on INET6_XFRM_MODE_TUNNEL
142+
select XFRM
176143
---help---
177144
Tunneling means encapsulating data of one protocol type within
178145
another protocol and sending it over a channel that understands the

net/ipv6/Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ obj-$(CONFIG_INET6_ESP_OFFLOAD) += esp6_offload.o
3535
obj-$(CONFIG_INET6_IPCOMP) += ipcomp6.o
3636
obj-$(CONFIG_INET6_XFRM_TUNNEL) += xfrm6_tunnel.o
3737
obj-$(CONFIG_INET6_TUNNEL) += tunnel6.o
38-
obj-$(CONFIG_INET6_XFRM_MODE_TRANSPORT) += xfrm6_mode_transport.o
39-
obj-$(CONFIG_INET6_XFRM_MODE_TUNNEL) += xfrm6_mode_tunnel.o
40-
obj-$(CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION) += xfrm6_mode_ro.o
41-
obj-$(CONFIG_INET6_XFRM_MODE_BEET) += xfrm6_mode_beet.o
4238
obj-$(CONFIG_IPV6_MIP6) += mip6.o
4339
obj-$(CONFIG_IPV6_ILA) += ila/
4440
obj-$(CONFIG_NETFILTER) += netfilter/

net/ipv6/ip6_vti.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ static int vti6_rcv_cb(struct sk_buff *skb, int err)
342342
struct net_device *dev;
343343
struct pcpu_sw_netstats *tstats;
344344
struct xfrm_state *x;
345-
struct xfrm_mode *inner_mode;
345+
const struct xfrm_mode *inner_mode;
346346
struct ip6_tnl *t = XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6;
347347
u32 orig_mark = skb->mark;
348348
int ret;

0 commit comments

Comments
 (0)