Skip to content

Commit c6b641a

Browse files
Vlad Yasevichdavem330
authored andcommitted
ipv6: Pull IPv6 GSO registration out of the module
Sing GSO support is now separate, pull it out of the module and make it its own init call. Remove the cleanup functions as they are no longer called. Signed-off-by: Vlad Yasevich <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 808a8f8 commit c6b641a

File tree

12 files changed

+36
-75
lines changed

12 files changed

+36
-75
lines changed

include/net/protocol.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define _PROTOCOL_H
2626

2727
#include <linux/in6.h>
28+
#include <linux/skbuff.h>
2829
#if IS_ENABLED(CONFIG_IPV6)
2930
#include <linux/ipv6.h>
3031
#endif
@@ -59,8 +60,6 @@ struct inet6_protocol {
5960

6061
#define INET6_PROTO_NOPOLICY 0x1
6162
#define INET6_PROTO_FINAL 0x2
62-
/* This should be set for any extension header which is compatible with GSO. */
63-
#define INET6_PROTO_GSO_EXTHDR 0x4
6463
#endif
6564

6665
struct net_offload {
@@ -72,6 +71,8 @@ struct net_offload {
7271
int (*gro_complete)(struct sk_buff *skb);
7372
unsigned int flags; /* Flags used by IPv6 for now */
7473
};
74+
/* This should be set for any extension header which is compatible with GSO. */
75+
#define INET6_PROTO_GSO_EXTHDR 0x1
7576

7677
/* This is used to register socket interfaces for IP protocols. */
7778
struct inet_protosw {
@@ -93,10 +94,10 @@ struct inet_protosw {
9394

9495
extern const struct net_protocol __rcu *inet_protos[MAX_INET_PROTOS];
9596
extern const struct net_offload __rcu *inet_offloads[MAX_INET_PROTOS];
97+
extern const struct net_offload __rcu *inet6_offloads[MAX_INET_PROTOS];
9698

9799
#if IS_ENABLED(CONFIG_IPV6)
98100
extern const struct inet6_protocol __rcu *inet6_protos[MAX_INET_PROTOS];
99-
extern const struct net_offload __rcu *inet6_offloads[MAX_INET_PROTOS];
100101
#endif
101102

102103
extern int inet_add_protocol(const struct net_protocol *prot, unsigned char num);
@@ -109,10 +110,10 @@ extern void inet_unregister_protosw(struct inet_protosw *p);
109110
#if IS_ENABLED(CONFIG_IPV6)
110111
extern int inet6_add_protocol(const struct inet6_protocol *prot, unsigned char num);
111112
extern int inet6_del_protocol(const struct inet6_protocol *prot, unsigned char num);
112-
extern int inet6_add_offload(const struct net_offload *prot, unsigned char num);
113-
extern int inet6_del_offload(const struct net_offload *prot, unsigned char num);
114113
extern int inet6_register_protosw(struct inet_protosw *p);
115114
extern void inet6_unregister_protosw(struct inet_protosw *p);
116115
#endif
116+
extern int inet6_add_offload(const struct net_offload *prot, unsigned char num);
117+
extern int inet6_del_offload(const struct net_offload *prot, unsigned char num);
117118

118119
#endif /* _PROTOCOL_H */

net/ipv6/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ obj-$(CONFIG_IPV6) += ipv6.o
77
ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o \
88
addrlabel.o \
99
route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o udplite.o \
10-
raw.o protocol.o icmp.o mcast.o reassembly.o tcp_ipv6.o \
10+
raw.o icmp.o mcast.o reassembly.o tcp_ipv6.o \
1111
exthdrs.o datagram.o ip6_flowlabel.o inet6_connection_sock.o
1212

1313
ipv6-offload := ip6_offload.o tcpv6_offload.o udp_offload.o exthdrs_offload.o
@@ -23,7 +23,6 @@ ipv6-$(CONFIG_PROC_FS) += proc.o
2323
ipv6-$(CONFIG_SYN_COOKIES) += syncookies.o
2424

2525
ipv6-objs += $(ipv6-y)
26-
ipv6-objs += $(ipv6-offload)
2726

2827
obj-$(CONFIG_INET6_AH) += ah6.o
2928
obj-$(CONFIG_INET6_ESP) += esp6.o
@@ -41,6 +40,7 @@ obj-$(CONFIG_IPV6_SIT) += sit.o
4140
obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o
4241
obj-$(CONFIG_IPV6_GRE) += ip6_gre.o
4342

44-
obj-y += addrconf_core.o exthdrs_core.o output_core.o
43+
obj-y += addrconf_core.o exthdrs_core.o output_core.o protocol.o
44+
obj-y += $(ipv6-offload)
4545

4646
obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_hashtables.o

net/ipv6/af_inet6.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262

6363
#include <asm/uaccess.h>
6464
#include <linux/mroute6.h>
65-
#include "ip6_offload.h"
6665

6766
MODULE_AUTHOR("Cast of dozens");
6867
MODULE_DESCRIPTION("IPv6 protocol stack for Linux");
@@ -707,14 +706,12 @@ static struct packet_type ipv6_packet_type __read_mostly = {
707706

708707
static int __init ipv6_packet_init(void)
709708
{
710-
ipv6_offload_init();
711709
dev_add_pack(&ipv6_packet_type);
712710
return 0;
713711
}
714712

715713
static void ipv6_packet_cleanup(void)
716714
{
717-
ipv6_offload_cleanup();
718715
dev_remove_pack(&ipv6_packet_type);
719716
}
720717

net/ipv6/exthdrs.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#endif
4949

5050
#include <asm/uaccess.h>
51-
#include "ip6_offload.h"
5251

5352
/*
5453
* Parsing tlv encoded headers.
@@ -502,13 +501,9 @@ int __init ipv6_exthdrs_init(void)
502501
{
503502
int ret;
504503

505-
ret = ipv6_exthdrs_offload_init();
506-
if (ret)
507-
goto out;
508-
509504
ret = inet6_add_protocol(&rthdr_protocol, IPPROTO_ROUTING);
510505
if (ret)
511-
goto out_offload;
506+
goto out;
512507

513508
ret = inet6_add_protocol(&destopt_protocol, IPPROTO_DSTOPTS);
514509
if (ret)
@@ -524,14 +519,11 @@ int __init ipv6_exthdrs_init(void)
524519
inet6_del_protocol(&destopt_protocol, IPPROTO_DSTOPTS);
525520
out_rthdr:
526521
inet6_del_protocol(&rthdr_protocol, IPPROTO_ROUTING);
527-
out_offload:
528-
ipv6_exthdrs_offload_exit();
529522
goto out;
530523
};
531524

532525
void ipv6_exthdrs_exit(void)
533526
{
534-
ipv6_exthdrs_offload_exit();
535527
inet6_del_protocol(&nodata_protocol, IPPROTO_NONE);
536528
inet6_del_protocol(&destopt_protocol, IPPROTO_DSTOPTS);
537529
inet6_del_protocol(&rthdr_protocol, IPPROTO_ROUTING);

net/ipv6/exthdrs_offload.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,3 @@ int __init ipv6_exthdrs_offload_init(void)
3939
inet_del_offload(&rthdr_offload, IPPROTO_ROUTING);
4040
goto out;
4141
}
42-
43-
void ipv6_exthdrs_offload_exit(void)
44-
{
45-
inet_del_offload(&rthdr_offload, IPPROTO_ROUTING);
46-
inet_del_offload(&rthdr_offload, IPPROTO_DSTOPTS);
47-
}

net/ipv6/ip6_offload.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/socket.h>
1313
#include <linux/netdevice.h>
1414
#include <linux/skbuff.h>
15+
#include <linux/printk.h>
1516

1617
#include <net/protocol.h>
1718
#include <net/ipv6.h>
@@ -262,12 +263,18 @@ static struct packet_offload ipv6_packet_offload __read_mostly = {
262263
.gro_complete = ipv6_gro_complete,
263264
};
264265

265-
void __init ipv6_offload_init(void)
266+
static int __init ipv6_offload_init(void)
266267
{
268+
269+
if (tcpv6_offload_init() < 0)
270+
pr_crit("%s: Cannot add TCP protocol offload\n", __func__);
271+
if (udp_offload_init() < 0)
272+
pr_crit("%s: Cannot add UDP protocol offload\n", __func__);
273+
if (ipv6_exthdrs_offload_init() < 0)
274+
pr_crit("%s: Cannot add EXTHDRS protocol offload\n", __func__);
275+
267276
dev_add_offload(&ipv6_packet_offload);
277+
return 0;
268278
}
269279

270-
void ipv6_offload_cleanup(void)
271-
{
272-
dev_remove_offload(&ipv6_packet_offload);
273-
}
280+
fs_initcall(ipv6_offload_init);

net/ipv6/ip6_offload.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,7 @@
1212
#define __ip6_offload_h
1313

1414
int ipv6_exthdrs_offload_init(void);
15-
void ipv6_exthdrs_offload_exit(void);
16-
1715
int udp_offload_init(void);
18-
void udp_offload_cleanup(void);
19-
2016
int tcpv6_offload_init(void);
21-
void tcpv6_offload_cleanup(void);
22-
23-
extern void ipv6_offload_init(void);
24-
extern void ipv6_offload_cleanup(void);
2517

2618
#endif

net/ipv6/protocol.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
#include <linux/spinlock.h>
2626
#include <net/protocol.h>
2727

28+
#if IS_ENABLED(CONFIG_IPV6)
2829
const struct inet6_protocol __rcu *inet6_protos[MAX_INET_PROTOS] __read_mostly;
29-
const struct net_offload __rcu *inet6_offloads[MAX_INET_PROTOS] __read_mostly;
30+
EXPORT_SYMBOL(inet6_protos);
3031

3132
int inet6_add_protocol(const struct inet6_protocol *prot, unsigned char protocol)
3233
{
@@ -35,13 +36,6 @@ int inet6_add_protocol(const struct inet6_protocol *prot, unsigned char protocol
3536
}
3637
EXPORT_SYMBOL(inet6_add_protocol);
3738

38-
int inet6_add_offload(const struct net_offload *prot, unsigned char protocol)
39-
{
40-
return !cmpxchg((const struct net_offload **)&inet6_offloads[protocol],
41-
NULL, prot) ? 0 : -1;
42-
}
43-
EXPORT_SYMBOL(inet6_add_offload);
44-
4539
/*
4640
* Remove a protocol from the hash tables.
4741
*/
@@ -58,6 +52,16 @@ int inet6_del_protocol(const struct inet6_protocol *prot, unsigned char protocol
5852
return ret;
5953
}
6054
EXPORT_SYMBOL(inet6_del_protocol);
55+
#endif
56+
57+
const struct net_offload __rcu *inet6_offloads[MAX_INET_PROTOS] __read_mostly;
58+
59+
int inet6_add_offload(const struct net_offload *prot, unsigned char protocol)
60+
{
61+
return !cmpxchg((const struct net_offload **)&inet6_offloads[protocol],
62+
NULL, prot) ? 0 : -1;
63+
}
64+
EXPORT_SYMBOL(inet6_add_offload);
6165

6266
int inet6_del_offload(const struct net_offload *prot, unsigned char protocol)
6367
{

net/ipv6/tcp_ipv6.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171

7272
#include <linux/crypto.h>
7373
#include <linux/scatterlist.h>
74-
#include "ip6_offload.h"
7574

7675
static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
7776
static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
@@ -2007,13 +2006,9 @@ int __init tcpv6_init(void)
20072006
{
20082007
int ret;
20092008

2010-
ret = tcpv6_offload_init();
2011-
if (ret)
2012-
goto out;
2013-
20142009
ret = inet6_add_protocol(&tcpv6_protocol, IPPROTO_TCP);
20152010
if (ret)
2016-
goto out_offload;
2011+
goto out;
20172012

20182013
/* register inet6 protocol */
20192014
ret = inet6_register_protosw(&tcpv6_protosw);
@@ -2030,8 +2025,6 @@ int __init tcpv6_init(void)
20302025
inet6_unregister_protosw(&tcpv6_protosw);
20312026
out_tcpv6_protocol:
20322027
inet6_del_protocol(&tcpv6_protocol, IPPROTO_TCP);
2033-
out_offload:
2034-
tcpv6_offload_cleanup();
20352028
goto out;
20362029
}
20372030

@@ -2040,5 +2033,4 @@ void tcpv6_exit(void)
20402033
unregister_pernet_subsys(&tcpv6_net_ops);
20412034
inet6_unregister_protosw(&tcpv6_protosw);
20422035
inet6_del_protocol(&tcpv6_protocol, IPPROTO_TCP);
2043-
tcpv6_offload_cleanup();
20442036
}

net/ipv6/tcpv6_offload.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,3 @@ int __init tcpv6_offload_init(void)
9191
{
9292
return inet6_add_offload(&tcpv6_offload, IPPROTO_TCP);
9393
}
94-
95-
void tcpv6_offload_cleanup(void)
96-
{
97-
inet6_del_offload(&tcpv6_offload, IPPROTO_TCP);
98-
}

net/ipv6/udp.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
#include <linux/seq_file.h>
5151
#include <trace/events/skb.h>
5252
#include "udp_impl.h"
53-
#include "ip6_offload.h"
5453

5554
int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
5655
{
@@ -1472,13 +1471,9 @@ int __init udpv6_init(void)
14721471
{
14731472
int ret;
14741473

1475-
ret = udp_offload_init();
1476-
if (ret)
1477-
goto out;
1478-
14791474
ret = inet6_add_protocol(&udpv6_protocol, IPPROTO_UDP);
14801475
if (ret)
1481-
goto out_offload;
1476+
goto out;
14821477

14831478
ret = inet6_register_protosw(&udpv6_protosw);
14841479
if (ret)
@@ -1488,14 +1483,11 @@ int __init udpv6_init(void)
14881483

14891484
out_udpv6_protocol:
14901485
inet6_del_protocol(&udpv6_protocol, IPPROTO_UDP);
1491-
out_offload:
1492-
udp_offload_cleanup();
14931486
goto out;
14941487
}
14951488

14961489
void udpv6_exit(void)
14971490
{
14981491
inet6_unregister_protosw(&udpv6_protosw);
14991492
inet6_del_protocol(&udpv6_protocol, IPPROTO_UDP);
1500-
udp_offload_cleanup();
15011493
}

net/ipv6/udp_offload.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,3 @@ int __init udp_offload_init(void)
115115
{
116116
return inet6_add_offload(&udpv6_offload, IPPROTO_UDP);
117117
}
118-
119-
void udp_offload_cleanup(void)
120-
{
121-
inet6_del_offload(&udpv6_offload, IPPROTO_UDP);
122-
}

0 commit comments

Comments
 (0)