diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index a934282b1a354110e40805e5052a902be8b401e0..0f7248fefb9868d99828ab8767fab67a6c6d696d 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2016,6 +2016,9 @@ struct net_device { struct dn_dev __rcu *dn_ptr; #endif struct inet6_dev __rcu *ip6_ptr; +#if IS_ENABLED(CONFIG_NEWIP) + struct ninet_dev __rcu *nip_ptr; /* NIP */ +#endif #if IS_ENABLED(CONFIG_AX25) void *ax25_ptr; #endif diff --git a/include/linux/socket.h b/include/linux/socket.h index 9aa530d497da8f738e2f2fd6f2d1b94bfd65c29c..fb098a938581a68d9bbcbc1a4b7b78874365a0b9 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -223,8 +223,8 @@ struct ucred { * reuses AF_INET address family */ #define AF_XDP 44 /* XDP sockets */ - -#define AF_MAX 45 /* For now.. */ +#define AF_NINET 45 /* NIP */ +#define AF_MAX 46 /* For now.. */ /* Protocol families, same as address families. */ #define PF_UNSPEC AF_UNSPEC @@ -274,6 +274,7 @@ struct ucred { #define PF_QIPCRTR AF_QIPCRTR #define PF_SMC AF_SMC #define PF_XDP AF_XDP +#define PF_NINET AF_NINET /* NIP */ #define PF_MAX AF_MAX /* Maximum queue length specifiable by listen. */ diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 2f87377e9af70b8b714f842170e0ba3ac9ffddf8..aaaecc45a4fcb8206e28c34a0adebb05a9f3e9ec 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -317,6 +317,9 @@ struct tcp_sock { /* OOO segments go in this rbtree. Socket lock must be held. */ struct rb_root out_of_order_queue; +#ifdef CONFIG_NEWIP + struct sk_buff *nip_out_of_order_queue; /* NIP */ +#endif struct sk_buff *ooo_last_skb; /* cache rb_last(out_of_order_queue) */ /* SACKs data, these 2 need to be together (see tcp_options_write) */ @@ -412,6 +415,22 @@ struct tcp_sock { */ struct request_sock __rcu *fastopen_rsk; struct saved_syn *saved_syn; + +#ifdef CONFIG_NEWIP +/* newip tcp retrans */ + u32 ack_retrans_num; + u32 ack_retrans_seq; + u32 nip_ssthresh; + u32 nip_ssthresh_reset; + bool nip_keepalive_enable; + u32 idle_ka_probes_out; + u32 nip_keepalive_out; + u32 last_rcv_nxt; + u32 dup_ack_cnt; + u32 keepalive_time_bak; + u32 keepalive_probes_bak; + u32 keepalive_intvl_bak; +#endif }; enum tsq_enum { diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index d4d611064a76f587217ac5b51b91d5df7814758e..3695a1802ea6939e6495963ab188468296dac279 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h @@ -82,6 +82,9 @@ struct inet_bind_bucket { kuid_t fastuid; #if IS_ENABLED(CONFIG_IPV6) struct in6_addr fast_v6_rcv_saddr; +#endif +#if IS_ENABLED(CONFIG_NEWIP) + struct nip_addr fast_nip_rcv_saddr; #endif __be32 fast_rcv_saddr; unsigned short fast_sk_family; diff --git a/include/net/neighbour.h b/include/net/neighbour.h index d5767e25509cc5dbac18ebe145aaf62133ced5b8..810b857f9531d37279e8c7287e21624defbcb8fe 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h @@ -232,6 +232,9 @@ enum { NEIGH_ARP_TABLE = 0, NEIGH_ND_TABLE = 1, NEIGH_DN_TABLE = 2, +#ifdef CONFIG_NEWIP + NEIGH_NND_TABLE = 3, /* NIP */ +#endif NEIGH_NR_TABLES, NEIGH_LINK_TABLE = NEIGH_NR_TABLES /* Pseudo table for neigh_xmit */ }; diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index eb0e7731f3b1c8c0e288d5963e8339a8dfa9ddf4..ac0f068f46fcee7dec858e92d3a3bf8892f8ded1 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -38,6 +38,9 @@ #include #include #include +#ifdef CONFIG_NEWIP +#include +#endif struct user_namespace; struct proc_dir_entry; @@ -127,6 +130,9 @@ struct net { #if IS_ENABLED(CONFIG_IPV6) struct netns_ipv6 ipv6; #endif +#if IS_ENABLED(CONFIG_NEWIP) + struct netns_newip newip; /* NIP */ +#endif #if IS_ENABLED(CONFIG_IEEE802154_6LOWPAN) struct netns_ieee802154_lowpan ieee802154_lowpan; #endif diff --git a/include/net/sock.h b/include/net/sock.h index 2c11eb4abdd246ba7ae6759f79376444c6774a50..477e7bc6831e06387114111a2970c6bc5d4663a1 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -68,6 +68,9 @@ #include #include #include +#ifdef CONFIG_NEWIP +#include +#endif /* * This structure really needs to be cleaned up. @@ -202,6 +205,11 @@ struct sock_common { struct in6_addr skc_v6_rcv_saddr; #endif +#if IS_ENABLED(CONFIG_NEWIP) + struct nip_addr nip_daddr; /* NIP */ + struct nip_addr nip_rcv_saddr; /* NIP */ +#endif + atomic64_t skc_cookie; /* following fields are padding to force diff --git a/include/net/tcp.h b/include/net/tcp.h index 334b8d1b54429225da51747143c7247328234708..b9b3ae0fa49c68e7f936697d62e08f55071c4b23 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -40,7 +40,9 @@ #include #include #include - +#ifdef CONFIG_NEWIP +#include /* NIP */ +#endif #include #include #include @@ -868,6 +870,9 @@ struct tcp_skb_cb { struct inet_skb_parm h4; #if IS_ENABLED(CONFIG_IPV6) struct inet6_skb_parm h6; +#endif +#if IS_ENABLED(CONFIG_NEWIP) + struct ninet_skb_parm hnip; /* NIP */ #endif } header; /* For incoming skbs */ struct { diff --git a/net/Makefile b/net/Makefile index 5744bf1997fd07aeb2a7a16e0e88d92a89a4d575..b02730775923eae5b8d87e7bbf96dd3bba13d7b5 100644 --- a/net/Makefile +++ b/net/Makefile @@ -20,6 +20,9 @@ obj-$(CONFIG_TLS) += tls/ obj-$(CONFIG_XFRM) += xfrm/ obj-$(CONFIG_UNIX_SCM) += unix/ obj-$(CONFIG_NET) += ipv6/ +ifeq ($(CONFIG_NEWIP),y) +obj-$(CONFIG_NET) += newip/ +endif obj-$(CONFIG_BPFILTER) += bpfilter/ obj-$(CONFIG_PACKET) += packet/ obj-$(CONFIG_NET_KEY) += key/ diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 52a1c8725337b7601c51355c8b8e26b381e18ae1..f36bd9d7dcd98035d98139ef19ceceee836b860f 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -1778,6 +1778,11 @@ static struct neigh_table *neigh_find_table(int family) case AF_DECnet: tbl = neigh_tables[NEIGH_DN_TABLE]; break; +#ifdef CONFIG_NEWIP + case AF_NINET: /* NIP */ + tbl = neigh_tables[NEIGH_NND_TABLE]; + break; +#endif } return tbl; diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index addd595bb3fe67cf4f2784f832ccc7bacf0207f5..f359192a4632b69f5a4a4ef714212b6fea6f04ae 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -22,6 +22,9 @@ #include #include #include +#if IS_ENABLED(CONFIG_NEWIP) +#include +#endif #if IS_ENABLED(CONFIG_IPV6) /* match_sk*_wildcard == true: IPV6_ADDR_ANY equals to any IPv6 addresses @@ -102,6 +105,16 @@ bool inet_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2, match_wildcard, match_wildcard); #endif + +#if IS_ENABLED(CONFIG_NEWIP) + if (sk->sk_family == AF_NINET) + return nip_rcv_saddr_equal(&sk->sk_nip_rcv_saddr, + &sk2->sk_nip_rcv_saddr, + sk2->sk_family == AF_NINET, + match_wildcard, + match_wildcard); +#endif + return ipv4_rcv_saddr_equal(sk->sk_rcv_saddr, sk2->sk_rcv_saddr, ipv6_only_sock(sk2), match_wildcard, match_wildcard); @@ -291,6 +304,13 @@ static inline int sk_reuseport_match(struct inet_bind_bucket *tb, sk->sk_rcv_saddr, tb->fast_ipv6_only, ipv6_only_sock(sk), true, false); +#endif +#if IS_ENABLED(CONFIG_NEWIP) + if (tb->fast_sk_family == AF_NINET) + return nip_rcv_saddr_equal(&tb->fast_nip_rcv_saddr, + &sk->sk_nip_rcv_saddr, + sk->sk_family == AF_NINET, + true, false); #endif return ipv4_rcv_saddr_equal(tb->fast_rcv_saddr, sk->sk_rcv_saddr, ipv6_only_sock(sk), true, false); @@ -312,6 +332,9 @@ void inet_csk_update_fastreuse(struct inet_bind_bucket *tb, tb->fast_sk_family = sk->sk_family; #if IS_ENABLED(CONFIG_IPV6) tb->fast_v6_rcv_saddr = sk->sk_v6_rcv_saddr; +#endif +#if IS_ENABLED(CONFIG_NEWIP) + tb->fast_nip_rcv_saddr = sk->sk_nip_rcv_saddr; #endif } else { tb->fastreuseport = 0; @@ -339,6 +362,9 @@ void inet_csk_update_fastreuse(struct inet_bind_bucket *tb, tb->fast_sk_family = sk->sk_family; #if IS_ENABLED(CONFIG_IPV6) tb->fast_v6_rcv_saddr = sk->sk_v6_rcv_saddr; +#endif +#if IS_ENABLED(CONFIG_NEWIP) + tb->fast_nip_rcv_saddr = sk->sk_nip_rcv_saddr; #endif } } else { diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index cf178d8eea81a30a84115f69753993557befff98..49fb529a939d1fad44f0b7d700b3cb781e9026f3 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -23,6 +23,9 @@ #if IS_ENABLED(CONFIG_IPV6) #include #endif +#if IS_ENABLED(CONFIG_NEWIP) +#include +#endif #include #include #include @@ -52,6 +55,15 @@ static u32 sk_ehashfn(const struct sock *sk) &sk->sk_v6_rcv_saddr, sk->sk_num, &sk->sk_v6_daddr, sk->sk_dport); #endif + +#if IS_ENABLED(CONFIG_NEWIP) + /* NIP */ + if (sk->sk_family == AF_NINET) + return ninet_ehashfn(sock_net(sk), + &sk->sk_nip_rcv_saddr, sk->sk_num, + &sk->sk_nip_daddr, sk->sk_dport); +#endif + return inet_ehashfn(sock_net(sk), sk->sk_rcv_saddr, sk->sk_num, sk->sk_daddr, sk->sk_dport); diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index ff2191ae53528d80a0890aa9f03989663559feaa..a45250a13d79481aaa95ee359149a0da49922fba 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1271,7 +1271,7 @@ static inline u16 socket_type_to_security_class(int family, int type, int protoc return SECCLASS_SMC_SOCKET; case PF_XDP: return SECCLASS_XDP_SOCKET; -#if PF_MAX > 45 +#if PF_MAX > 46 #error New address family defined, please update this function. #endif } diff --git a/security/selinux/include/classmap.h b/security/selinux/include/classmap.h index b9fdba2ff41637ca0daf2d8779fd23d2339c0190..7271a0e05966f4a81ebdf231d6bc0d4cdff14325 100644 --- a/security/selinux/include/classmap.h +++ b/security/selinux/include/classmap.h @@ -253,6 +253,6 @@ struct security_class_mapping secclass_map[] = { { NULL } }; -#if PF_MAX > 45 +#if PF_MAX > 46 #error New address family defined, please update secclass_map. #endif