Make it possible to build IP stack as a module

This is not pretty, but it works.
This commit is contained in:
Ole André Vadla Ravnås 2022-05-10 00:47:37 +02:00
parent 9dc4573cce
commit 77b228276c
26 changed files with 1494 additions and 25 deletions

View file

@ -40,7 +40,14 @@ obj-$(CONFIG_IPV6_SIT) += sit.o
obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o
obj-$(CONFIG_IPV6_GRE) += ip6_gre.o
ifeq ($(CONFIG_INET),m)
ipv6-y += ip6_icmp.o
ipv6-y += output_core.o protocol.o $(ipv6-offload)
ipv6-y += inet6_hashtables.o
else
obj-y += addrconf_core.o exthdrs_core.o ip6_checksum.o ip6_icmp.o
obj-$(CONFIG_INET) += output_core.o protocol.o $(ipv6-offload)
obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_hashtables.o
endif

View file

@ -77,6 +77,8 @@ static inline int current_has_network(void)
}
#endif
#include "ip6_offload.h"
MODULE_AUTHOR("Cast of dozens");
MODULE_DESCRIPTION("IPv6 protocol stack for Linux");
MODULE_LICENSE("GPL");
@ -850,6 +852,8 @@ static int __init inet6_init(void)
BUILD_BUG_ON(sizeof(struct inet6_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
ipv6_offload_init();
/* Register the socket-side information for inet6_create. */
for (r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r)
INIT_LIST_HEAD(r);

View file

@ -20,7 +20,7 @@ static const struct net_offload dstopt_offload = {
.flags = INET6_PROTO_GSO_EXTHDR,
};
int __init ipv6_exthdrs_offload_init(void)
int ipv6_exthdrs_offload_init(void)
{
int ret;

View file

@ -264,7 +264,7 @@ static struct packet_offload ipv6_packet_offload __read_mostly = {
},
};
static int __init ipv6_offload_init(void)
void ipv6_offload_init(void)
{
if (tcpv6_offload_init() < 0)
@ -275,7 +275,4 @@ static int __init ipv6_offload_init(void)
pr_crit("%s: Cannot add EXTHDRS protocol offload\n", __func__);
dev_add_offload(&ipv6_packet_offload);
return 0;
}
fs_initcall(ipv6_offload_init);

View file

@ -11,6 +11,7 @@
#ifndef __ip6_offload_h
#define __ip6_offload_h
void ipv6_offload_init(void);
int ipv6_exthdrs_offload_init(void);
int udp_offload_init(void);
int tcpv6_offload_init(void);

View file

@ -1945,7 +1945,7 @@ struct proto tcpv6_prot = {
.compat_setsockopt = compat_tcp_setsockopt,
.compat_getsockopt = compat_tcp_getsockopt,
#endif
#ifdef CONFIG_MEMCG_KMEM
#if defined(CONFIG_MEMCG_KMEM) && !defined(CONFIG_INET_MODULE)
.proto_cgroup = tcp_proto_cgroup,
#endif
.clear_sk = tcp_v6_clear_sk,

View file

@ -89,7 +89,7 @@ static const struct net_offload tcpv6_offload = {
},
};
int __init tcpv6_offload_init(void)
int tcpv6_offload_init(void)
{
return inet6_add_offload(&tcpv6_offload, IPPROTO_TCP);
}

View file

@ -125,7 +125,7 @@ static const struct net_offload udpv6_offload = {
},
};
int __init udp_offload_init(void)
int udp_offload_init(void)
{
return inet6_add_offload(&udpv6_offload, IPPROTO_UDP);
}