2023-10-22 16:20:12

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 00/17] Change cork to a pointer in sockets

This patch changes the cork field of both the inet_sock and inet6_sk
structs to a pointer, reducing their size.

Oliver Crumrine (17):
Make cork in inet_sock a pointer.
Allocate and free cork in inet_create and inet_release in file
net/ipv4/af_inet.c
Change cork in ipv6_pinfo to a pointer.
Allocate and free cork in inet6_sk.
Change occurence of cork in inet_sock to pointer in include/net/ip.h
Since cork in inet_sock and inet6_sk will be a pointer, they don't
need to be referenced in this function in include/net/ipv6.h
Change occurences of cork in inet_sock to pointer in file
net/ipv4/af_inet.c
Change occurence of cork to pointer in file net/ipv4/datagram.c
Change instances of cork in net/ipv4/inet_connection_sock.c to
pointer.
Change instances of cork to pointer in net/ipv4/ip_output.c
Update occurences of cork to pointer in net/ipv4/syncookies.c
Change occurences of cork to pointer in net/ipv4/tcp_output.c
Change instances of cork to a pointer in file net/ipv4/udp.c
Update usages of cork in net/ipv6/ip6_output.c to pointer.
Modify occurences of cork in net/ipv6/raw.c to use a pointer
Change usages of cork to pointer in net/ipv6/udp.c
Change instance of cork to pointer in net/ipv4/tcp_ipv4.c

include/linux/ipv6.h | 2 +-
include/net/inet_sock.h | 2 +-
include/net/ip.h | 2 +-
include/net/ipv6.h | 4 ++--
net/ipv4/af_inet.c | 6 ++++--
net/ipv4/datagram.c | 2 +-
net/ipv4/inet_connection_sock.c | 6 +++---
net/ipv4/ip_output.c | 6 +++---
net/ipv4/syncookies.c | 2 +-
net/ipv4/tcp_ipv4.c | 2 +-
net/ipv4/tcp_output.c | 2 +-
net/ipv4/udp.c | 8 ++++----
net/ipv6/af_inet6.c | 5 +++++
net/ipv6/ip6_output.c | 10 +++++-----
net/ipv6/raw.c | 4 ++--
net/ipv6/udp.c | 4 ++--
16 files changed, 37 insertions(+), 30 deletions(-)

--
2.42.0


2023-10-22 16:20:30

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 02/17] Allocate and free cork for ipv4 and ipv6

This allocates the cork for ipv4, and frees it for both ipv4 and ipv6
(ipv6 inet_cork_full is allocated in a different function)

Signed-off-by: Oliver Crumrine <[email protected]>
---
net/ipv4/af_inet.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 2713c9b06c4c..3edfd8737715 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -362,6 +362,7 @@ static int inet_create(struct net *net, struct socket *sock, int protocol,
inet->mc_index = 0;
inet->mc_list = NULL;
inet->rcv_tos = 0;
+ inet->cork = kzalloc(sizeof(struct inet_cork_full), GFP_KERNEL);

if (inet->inet_num) {
/* It assumes that any protocol which allows
@@ -431,6 +432,7 @@ int inet_release(struct socket *sock)
!(current->flags & PF_EXITING))
timeout = sk->sk_lingertime;
sk->sk_prot->close(sk, timeout);
+ kfree(inet_sk(sk)->cork);
sock->sk = NULL;
}
return 0;
--
2.42.0

2023-10-22 16:20:30

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 01/17] Make cork in inet_sock a pointer.

Change the cork in inet_sock to a pointer. This is the actual change
to the struct itself for ipv4.

Signed-off-by: Oliver Crumrine <[email protected]>
---
include/net/inet_sock.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index 2de0e4d4a027..335cd6b2d472 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -240,7 +240,7 @@ struct inet_sock {
} local_port_range;

struct ip_mc_socklist __rcu *mc_list;
- struct inet_cork_full cork;
+ struct inet_cork_full *cork;
};

#define IPCORK_OPT 1 /* ip-options has been held in ipcork.opt */
--
2.42.0

2023-10-22 16:20:40

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 03/17] Change cork in ipv6_pinfo to a pointer.

The actual change to make inet6_cork a pointer in the ipv6_pinfo struct
itself.

Signed-off-by: Oliver Crumrine <[email protected]>
---
include/linux/ipv6.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index af8a771a053c..0c707ce9e776 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -290,7 +290,7 @@ struct ipv6_pinfo {
struct ipv6_txoptions __rcu *opt;
struct sk_buff *pktoptions;
struct sk_buff *rxpmtu;
- struct inet6_cork cork;
+ struct inet6_cork *cork;
};

/* WARNING: don't change the layout of the members in {raw,udp,tcp}6_sock! */
--
2.42.0

2023-10-22 16:20:59

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 04/17] Allocate and free cork in inet6_sk.

Allocate both the inet6_cork and inet_cork_full here, and free the
inet6_cork. (The inet_cork_full is freed in inet_release called at
the last line of inet6_release)

Signed-off-by: Oliver Crumrine <[email protected]>
---
net/ipv6/af_inet6.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 368824fe9719..33e92826361f 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -221,6 +221,7 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,
np->mc_all = 1;
np->pmtudisc = IPV6_PMTUDISC_WANT;
np->repflow = net->ipv6.sysctl.flowlabel_reflect & FLOWLABEL_REFLECT_ESTABLISHED;
+ np->cork = kzalloc(sizeof(struct inet6_cork), GFP_KERNEL);
sk->sk_ipv6only = net->ipv6.sysctl.bindv6only;
sk->sk_txrehash = READ_ONCE(net->core.sysctl_txrehash);

@@ -234,6 +235,7 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,
inet->mc_index = 0;
RCU_INIT_POINTER(inet->mc_list, NULL);
inet->rcv_tos = 0;
+ inet->cork = kzalloc(sizeof(struct inet_cork_full), GFP_KERNEL);

if (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc))
inet->pmtudisc = IP_PMTUDISC_DONT;
@@ -481,6 +483,9 @@ int inet6_release(struct socket *sock)
/* Free ac lists */
ipv6_sock_ac_close(sk);

+ /* Free cork */
+ kfree(inet6_sk(sk)->cork);
+
return inet_release(sock);
}
EXPORT_SYMBOL(inet6_release);
--
2.42.0

2023-10-22 16:21:36

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 05/17] Change occurence of cork to pointer

Change cork to pointer in accordance with the previous patches in the
set.

Signed-off-by: Oliver Crumrine <[email protected]>
---
include/net/ip.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/ip.h b/include/net/ip.h
index 3489a1cca5e7..30bef1828a7d 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -240,7 +240,7 @@ int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl);

static inline struct sk_buff *ip_finish_skb(struct sock *sk, struct flowi4 *fl4)
{
- return __ip_make_skb(sk, fl4, &sk->sk_write_queue, &inet_sk(sk)->cork.base);
+ return __ip_make_skb(sk, fl4, &sk->sk_write_queue, &inet_sk(sk)->cork->base);
}

/* Get the route scope that should be used when sending a packet. */
--
2.42.0

2023-10-22 16:21:44

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 08/17] Update cork to pointer

Updates cork to a pointer in the __ip4_datagram_connect function in
accordance with the previous patches.

Signed-off-by: Oliver Crumrine <[email protected]>
---
net/ipv4/datagram.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
index cb5dbee9e018..bb73eae9de25 100644
--- a/net/ipv4/datagram.c
+++ b/net/ipv4/datagram.c
@@ -45,7 +45,7 @@ int __ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
} else if (!oif) {
oif = inet->uc_index;
}
- fl4 = &inet->cork.fl.u.ip4;
+ fl4 = &inet->cork->fl.u.ip4;
rt = ip_route_connect(fl4, usin->sin_addr.s_addr, saddr, oif,
sk->sk_protocol, inet->inet_sport,
usin->sin_port, sk);
--
2.42.0

2023-10-22 16:21:45

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 09/17] Change instances of cork to a pointer

Make these usages of the cork a pointer in accordance with the previous
patches.

Signed-off-by: Oliver Crumrine <[email protected]>
---
net/ipv4/inet_connection_sock.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 394a498c2823..99eb394ba0a3 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -830,7 +830,7 @@ struct dst_entry *inet_csk_route_child_sock(const struct sock *sk,
struct rtable *rt;

opt = rcu_dereference(ireq->ireq_opt);
- fl4 = &newinet->cork.fl.u.ip4;
+ fl4 = &newinet->cork->fl.u.ip4;

flowi4_init_output(fl4, ireq->ir_iif, ireq->ir_mark,
ip_sock_rt_tos(sk), ip_sock_rt_scope(sk),
@@ -1482,7 +1482,7 @@ struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu)
struct inet_sock *inet = inet_sk(sk);

if (!dst) {
- dst = inet_csk_rebuild_route(sk, &inet->cork.fl);
+ dst = inet_csk_rebuild_route(sk, &inet->cork->fl);
if (!dst)
goto out;
}
@@ -1490,7 +1490,7 @@ struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu)

dst = __sk_dst_check(sk, 0);
if (!dst)
- dst = inet_csk_rebuild_route(sk, &inet->cork.fl);
+ dst = inet_csk_rebuild_route(sk, &inet->cork->fl);
out:
return dst;
}
--
2.42.0

2023-10-22 16:21:48

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 12/17] Change an occurence of cork to pointer

Changes this occurence of cork to a pointer

Signed-off-by: Oliver Crumrine <[email protected]>
---
net/ipv4/tcp_output.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index f0723460753c..9672eaeb3ec1 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1414,7 +1414,7 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb,

err = INDIRECT_CALL_INET(icsk->icsk_af_ops->queue_xmit,
inet6_csk_xmit, ip_queue_xmit,
- sk, skb, &inet->cork.fl);
+ sk, skb, &inet->cork->fl);

if (unlikely(err > 0)) {
tcp_enter_cwr(sk);
--
2.42.0

2023-10-22 16:21:53

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 11/17] Update occurences of cork to pointer

Updates an occurence of cork to a pointer in accordance with the
previous patches in the set

Signed-off-by: Oliver Crumrine <[email protected]>
---
net/ipv4/syncookies.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index dc478a0574cb..4354a4decb51 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -450,6 +450,6 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)
* Normal sockets get it right from inet_csk_route_child_sock()
*/
if (ret)
- inet_sk(ret)->cork.fl.u.ip4 = fl4;
+ inet_sk(ret)->cork->fl.u.ip4 = fl4;
out: return ret;
}
--
2.42.0

2023-10-22 16:22:08

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 14/17] Update usages of cork to a pointer

Modify a few instances of cork to be a pointer

Signed-off-by: Oliver Crumrine <[email protected]>
---
net/ipv6/ip6_output.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 54fc4c711f2c..5f24087bc9e2 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1878,12 +1878,12 @@ int ip6_append_data(struct sock *sk,
* setup for corking
*/
dst_hold(&rt->dst);
- err = ip6_setup_cork(sk, &inet->cork, &np->cork,
+ err = ip6_setup_cork(sk, inet->cork, np->cork,
ipc6, rt);
if (err)
return err;

- inet->cork.fl.u.ip6 = *fl6;
+ inet->cork->fl.u.ip6 = *fl6;
exthdrlen = (ipc6->opt ? ipc6->opt->opt_flen : 0);
length += exthdrlen;
transhdrlen += exthdrlen;
@@ -1891,8 +1891,8 @@ int ip6_append_data(struct sock *sk,
transhdrlen = 0;
}

- return __ip6_append_data(sk, &sk->sk_write_queue, &inet->cork,
- &np->cork, sk_page_frag(sk), getfrag,
+ return __ip6_append_data(sk, &sk->sk_write_queue, inet->cork,
+ np->cork, sk_page_frag(sk), getfrag,
from, length, transhdrlen, flags, ipc6);
}
EXPORT_SYMBOL_GPL(ip6_append_data);
@@ -2058,7 +2058,7 @@ static void __ip6_flush_pending_frames(struct sock *sk,
void ip6_flush_pending_frames(struct sock *sk)
{
__ip6_flush_pending_frames(sk, &sk->sk_write_queue,
- &inet_sk(sk)->cork, &inet6_sk(sk)->cork);
+ inet_sk(sk)->cork, inet6_sk(sk)->cork);
}
EXPORT_SYMBOL_GPL(ip6_flush_pending_frames);

--
2.42.0

2023-10-22 16:22:22

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 13/17] Change some instances of cork to a pointer

Changes a few instances of cork to a pointer in accordance with the
previous patches

Signed-off-by: Oliver Crumrine <[email protected]>
---
net/ipv4/udp.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index f39b9c844580..51b64024124b 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -981,7 +981,7 @@ int udp_push_pending_frames(struct sock *sk)
{
struct udp_sock *up = udp_sk(sk);
struct inet_sock *inet = inet_sk(sk);
- struct flowi4 *fl4 = &inet->cork.fl.u.ip4;
+ struct flowi4 *fl4 = &inet->cork->fl.u.ip4;
struct sk_buff *skb;
int err = 0;

@@ -989,7 +989,7 @@ int udp_push_pending_frames(struct sock *sk)
if (!skb)
goto out;

- err = udp_send_skb(skb, fl4, &inet->cork.base);
+ err = udp_send_skb(skb, fl4, &inet->cork->base);

out:
up->len = 0;
@@ -1068,7 +1068,7 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)

getfrag = is_udplite ? udplite_getfrag : ip_generic_getfrag;

- fl4 = &inet->cork.fl.u.ip4;
+ fl4 = &inet->cork->fl.u.ip4;
if (up->pending) {
/*
* There are pending frames.
@@ -1260,7 +1260,7 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
/*
* Now cork the socket to pend data.
*/
- fl4 = &inet->cork.fl.u.ip4;
+ fl4 = &inet->cork->fl.u.ip4;
fl4->daddr = daddr;
fl4->saddr = saddr;
fl4->fl4_dport = dport;
--
2.42.0

2023-10-22 16:22:23

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 15/17] Modify occurences of cork to make it a pointer

Update an occurence of ockr to make it a pointer, just like all the
previous patches

Signed-off-by: Oliver Crumrine <[email protected]>
---
net/ipv6/raw.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 42fcec3ecf5e..3ef5a75dcb79 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -520,8 +520,8 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi6 *fl6,
goto out;

offset = rp->offset;
- total_len = inet_sk(sk)->cork.base.length;
- opt = inet6_sk(sk)->cork.opt;
+ total_len = inet_sk(sk)->cork->base.length;
+ opt = inet6_sk(sk)->cork->opt;
total_len -= opt ? opt->opt_flen : 0;

if (offset >= total_len - 1) {
--
2.42.0

2023-10-22 16:22:29

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 06/17] Update code for cork as a pointer

Because the corks are pointers, they don't need to be referenced to be
passed into __ip6_make_skb.

Signed-off-by: Oliver Crumrine <[email protected]>
---
include/net/ipv6.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index c6932d1a3fa8..88eded2662ff 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -1122,8 +1122,8 @@ struct sk_buff *ip6_make_skb(struct sock *sk,

static inline struct sk_buff *ip6_finish_skb(struct sock *sk)
{
- return __ip6_make_skb(sk, &sk->sk_write_queue, &inet_sk(sk)->cork,
- &inet6_sk(sk)->cork);
+ return __ip6_make_skb(sk, &sk->sk_write_queue, inet_sk(sk)->cork,
+ inet6_sk(sk)->cork);
}

int ip6_dst_lookup(struct net *net, struct sock *sk, struct dst_entry **dst,
--
2.42.0

2023-10-22 16:22:30

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 07/17] Change occurences of cork to pointer

Change two occurences of cork to a pointer in both inet_sk_reselect_saddr,
and inet_sk_rebuild_header.

Signed-off-by: Oliver Crumrine <[email protected]>
---
net/ipv4/af_inet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 3edfd8737715..60f693040a2c 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1263,7 +1263,7 @@ static int inet_sk_reselect_saddr(struct sock *sk)
daddr = inet_opt->opt.faddr;

/* Query new route. */
- fl4 = &inet->cork.fl.u.ip4;
+ fl4 = &inet->cork->fl.u.ip4;
rt = ip_route_connect(fl4, daddr, 0, sk->sk_bound_dev_if,
sk->sk_protocol, inet->inet_sport,
inet->inet_dport, sk);
@@ -1321,7 +1321,7 @@ int inet_sk_rebuild_header(struct sock *sk)
if (inet_opt && inet_opt->opt.srr)
daddr = inet_opt->opt.faddr;
rcu_read_unlock();
- fl4 = &inet->cork.fl.u.ip4;
+ fl4 = &inet->cork->fl.u.ip4;
rt = ip_route_output_ports(sock_net(sk), fl4, sk, daddr, inet->inet_saddr,
inet->inet_dport, inet->inet_sport,
sk->sk_protocol, RT_CONN_FLAGS(sk),
--
2.42.0

2023-10-22 16:22:32

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 16/17] Change a usage of cork to pointer

Change an instance of cork to a pointer in accordance with the other
patches in this set

Signed-off-by: Oliver Crumrine <[email protected]>
---
net/ipv6/udp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 86b5d509a468..191d21d12a98 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1306,8 +1306,8 @@ static int udp_v6_push_pending_frames(struct sock *sk)
if (!skb)
goto out;

- err = udp_v6_send_skb(skb, &inet_sk(sk)->cork.fl.u.ip6,
- &inet_sk(sk)->cork.base);
+ err = udp_v6_send_skb(skb, &inet_sk(sk)->cork->fl.u.ip6,
+ &inet_sk(sk)->cork->base);
out:
up->len = 0;
up->pending = 0;
--
2.42.0

2023-10-22 16:24:35

by Oliver Crumrine

[permalink] [raw]
Subject: [PATCH net-next 17/17] Change the last instance of cork to pointer

Change the last of the instances of cork to a pointer.

Signed-off-by: Oliver Crumrine <[email protected]>
---
net/ipv4/tcp_ipv4.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 4167e8a48b60..b6729817378f 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -229,7 +229,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)

orig_sport = inet->inet_sport;
orig_dport = usin->sin_port;
- fl4 = &inet->cork.fl.u.ip4;
+ fl4 = &inet->cork->fl.u.ip4;
rt = ip_route_connect(fl4, nexthop, inet->inet_saddr,
sk->sk_bound_dev_if, IPPROTO_TCP, orig_sport,
orig_dport, sk);
--
2.42.0

2023-10-23 07:06:42

by Ravi Gunasekaran

[permalink] [raw]
Subject: Re: [PATCH net-next 01/17] Make cork in inet_sock a pointer.



On 10/22/23 9:50 PM, Oliver Crumrine wrote:
> Change the cork in inet_sock to a pointer. This is the actual change
> to the struct itself for ipv4.
>
> Signed-off-by: Oliver Crumrine <[email protected]>
> ---
> include/net/inet_sock.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
> index 2de0e4d4a027..335cd6b2d472 100644
> --- a/include/net/inet_sock.h
> +++ b/include/net/inet_sock.h
> @@ -240,7 +240,7 @@ struct inet_sock {
> } local_port_range;
>
> struct ip_mc_socklist __rcu *mc_list;
> - struct inet_cork_full cork;
> + struct inet_cork_full *cork;
> };
>
> #define IPCORK_OPT 1 /* ip-options has been held in ipcork.opt */

Please make sure each patch in the series in buildable. This helps during a
git bisect.

--
Regards,
Ravi

2023-10-23 08:25:59

by Paolo Abeni

[permalink] [raw]
Subject: Re: [PATCH net-next 00/17] Change cork to a pointer in sockets

On Sun, 2023-10-22 at 12:19 -0400, Oliver Crumrine wrote:
> This patch changes the cork field of both the inet_sock and inet6_sk
> structs to a pointer, reducing their size.
>
> Oliver Crumrine (17):
> Make cork in inet_sock a pointer.
> Allocate and free cork in inet_create and inet_release in file
> net/ipv4/af_inet.c
> Change cork in ipv6_pinfo to a pointer.
> Allocate and free cork in inet6_sk.
> Change occurence of cork in inet_sock to pointer in include/net/ip.h
> Since cork in inet_sock and inet6_sk will be a pointer, they don't
> need to be referenced in this function in include/net/ipv6.h
> Change occurences of cork in inet_sock to pointer in file
> net/ipv4/af_inet.c
> Change occurence of cork to pointer in file net/ipv4/datagram.c
> Change instances of cork in net/ipv4/inet_connection_sock.c to
> pointer.
> Change instances of cork to pointer in net/ipv4/ip_output.c
> Update occurences of cork to pointer in net/ipv4/syncookies.c
> Change occurences of cork to pointer in net/ipv4/tcp_output.c
> Change instances of cork to a pointer in file net/ipv4/udp.c
> Update usages of cork in net/ipv6/ip6_output.c to pointer.
> Modify occurences of cork in net/ipv6/raw.c to use a pointer
> Change usages of cork to pointer in net/ipv6/udp.c
> Change instance of cork to pointer in net/ipv4/tcp_ipv4.c
>
> include/linux/ipv6.h | 2 +-
> include/net/inet_sock.h | 2 +-
> include/net/ip.h | 2 +-
> include/net/ipv6.h | 4 ++--
> net/ipv4/af_inet.c | 6 ++++--
> net/ipv4/datagram.c | 2 +-
> net/ipv4/inet_connection_sock.c | 6 +++---
> net/ipv4/ip_output.c | 6 +++---
> net/ipv4/syncookies.c | 2 +-
> net/ipv4/tcp_ipv4.c | 2 +-
> net/ipv4/tcp_output.c | 2 +-
> net/ipv4/udp.c | 8 ++++----
> net/ipv6/af_inet6.c | 5 +++++
> net/ipv6/ip6_output.c | 10 +++++-----
> net/ipv6/raw.c | 4 ++--
> net/ipv6/udp.c | 4 ++--
> 16 files changed, 37 insertions(+), 30 deletions(-)

Could you please explain the rationale behind such changes? 

As the cork struct is still allocated for each inet/inet6 socket, the
total memory used by the the now smaller socket struct and the cork
struct will be greater then the memory used originally by such socket.
And the double allocation/free will be slower then the original one.

This also adds a bunch of additional pointer de-reference in the xmit
path.

Finally the above change will probably conflict with the goodies
introduced by:

https://lore.kernel.org/netdev/[email protected]/

I'm sorry, but this looks really a no-go.

Before future submissions, please read thoroughly the process
documentation, including the netdev specific bits in maintainer-
netdev.rst: there a bit of issues with the process here (the recipients
list does not include a lot of relevant ones, there are typos there,
the patch series is too long, it breaks the builds ...)

Cheers,

Paolo