Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c720c7e8 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

inet: rename some inet_sock fields



In order to have better cache layouts of struct sock (separate zones
for rx/tx paths), we need this preliminary patch.

Goal is to transfert fields used at lookup time in the first
read-mostly cache line (inside struct sock_common) and move sk_refcnt
to a separate cache line (only written by rx path)

This patch adds inet_ prefix to daddr, rcv_saddr, dport, num, saddr,
sport and id fields. This allows a future patch to define these
fields as macros, like sk_refcnt, without name clashes.

Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 988ade6b
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -516,7 +516,7 @@ static inline int pppol2tp_verify_udp_checksum(struct sock *sk,
		return 0;

	inet = inet_sk(sk);
	psum = csum_tcpudp_nofold(inet->saddr, inet->daddr, ulen,
	psum = csum_tcpudp_nofold(inet->inet_saddr, inet->inet_daddr, ulen,
				  IPPROTO_UDP, 0);

	if ((skb->ip_summed == CHECKSUM_COMPLETE) &&
@@ -949,8 +949,8 @@ static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msgh
	inet = inet_sk(sk_tun);
	udp_len = hdr_len + sizeof(ppph) + total_len;
	uh = (struct udphdr *) skb->data;
	uh->source = inet->sport;
	uh->dest = inet->dport;
	uh->source = inet->inet_sport;
	uh->dest = inet->inet_dport;
	uh->len = htons(udp_len);
	uh->check = 0;
	skb_put(skb, sizeof(struct udphdr));
@@ -978,7 +978,8 @@ static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msgh
	else if (!(skb_dst(skb)->dev->features & NETIF_F_V4_CSUM)) {
		skb->ip_summed = CHECKSUM_COMPLETE;
		csum = skb_checksum(skb, 0, udp_len, 0);
		uh->check = csum_tcpudp_magic(inet->saddr, inet->daddr,
		uh->check = csum_tcpudp_magic(inet->inet_saddr,
					      inet->inet_daddr,
					      udp_len, IPPROTO_UDP, csum);
		if (uh->check == 0)
			uh->check = CSUM_MANGLED_0;
@@ -986,7 +987,8 @@ static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msgh
		skb->ip_summed = CHECKSUM_PARTIAL;
		skb->csum_start = skb_transport_header(skb) - skb->head;
		skb->csum_offset = offsetof(struct udphdr, check);
		uh->check = ~csum_tcpudp_magic(inet->saddr, inet->daddr,
		uh->check = ~csum_tcpudp_magic(inet->inet_saddr,
					       inet->inet_daddr,
					       udp_len, IPPROTO_UDP, 0);
	}

@@ -1136,8 +1138,8 @@ static int pppol2tp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
	__skb_push(skb, sizeof(*uh));
	skb_reset_transport_header(skb);
	uh = udp_hdr(skb);
	uh->source = inet->sport;
	uh->dest = inet->dport;
	uh->source = inet->inet_sport;
	uh->dest = inet->inet_dport;
	uh->len = htons(udp_len);
	uh->check = 0;

@@ -1181,7 +1183,8 @@ static int pppol2tp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
	else if (!(skb_dst(skb)->dev->features & NETIF_F_V4_CSUM)) {
		skb->ip_summed = CHECKSUM_COMPLETE;
		csum = skb_checksum(skb, 0, udp_len, 0);
		uh->check = csum_tcpudp_magic(inet->saddr, inet->daddr,
		uh->check = csum_tcpudp_magic(inet->inet_saddr,
					      inet->inet_daddr,
					      udp_len, IPPROTO_UDP, csum);
		if (uh->check == 0)
			uh->check = CSUM_MANGLED_0;
@@ -1189,7 +1192,8 @@ static int pppol2tp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
		skb->ip_summed = CHECKSUM_PARTIAL;
		skb->csum_start = skb_transport_header(skb) - skb->head;
		skb->csum_offset = offsetof(struct udphdr, check);
		uh->check = ~csum_tcpudp_magic(inet->saddr, inet->daddr,
		uh->check = ~csum_tcpudp_magic(inet->inet_saddr,
					       inet->inet_daddr,
					       udp_len, IPPROTO_UDP, 0);
	}

+4 −4
Original line number Diff line number Diff line
@@ -294,10 +294,10 @@ static int sc_seq_show(struct seq_file *seq, void *v)
		if (sc->sc_sock) {
			inet = inet_sk(sc->sc_sock->sk);
			/* the stack's structs aren't sparse endian clean */
			saddr = (__force __be32)inet->saddr;
			daddr = (__force __be32)inet->daddr;
			sport = (__force __be16)inet->sport;
			dport = (__force __be16)inet->dport;
			saddr = (__force __be32)inet->inet_saddr;
			daddr = (__force __be32)inet->inet_daddr;
			sport = (__force __be16)inet->inet_sport;
			dport = (__force __be16)inet->inet_dport;
		}

		/* XXX sigh, inet-> doesn't have sparse annotation so any
+1 −1
Original line number Diff line number Diff line
@@ -505,7 +505,7 @@ static inline struct raw6_sock *raw6_sk(const struct sock *sk)

#define INET6_MATCH(__sk, __net, __hash, __saddr, __daddr, __ports, __dif)\
	(((__sk)->sk_hash == (__hash)) && sock_net((__sk)) == (__net)	&& \
	 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports))  	&& \
	 ((*((__portpair *)&(inet_sk(__sk)->inet_dport))) == (__ports)) && \
	 ((__sk)->sk_family		== AF_INET6)		&& \
	 ipv6_addr_equal(&inet6_sk(__sk)->daddr, (__saddr))	&& \
	 ipv6_addr_equal(&inet6_sk(__sk)->rcv_saddr, (__daddr))	&& \
+2 −2
Original line number Diff line number Diff line
@@ -46,8 +46,8 @@ static inline int inet6_sk_ehashfn(const struct sock *sk)
	const struct ipv6_pinfo *np = inet6_sk(sk);
	const struct in6_addr *laddr = &np->rcv_saddr;
	const struct in6_addr *faddr = &np->daddr;
	const __u16 lport = inet->num;
	const __be16 fport = inet->dport;
	const __u16 lport = inet->inet_num;
	const __be16 fport = inet->inet_dport;
	struct net *net = sock_net(sk);

	return inet6_ehashfn(net, laddr, lport, faddr, fport);
+6 −6
Original line number Diff line number Diff line
@@ -241,7 +241,7 @@ static inline int inet_lhashfn(struct net *net, const unsigned short num)

static inline int inet_sk_listen_hashfn(const struct sock *sk)
{
	return inet_lhashfn(sock_net(sk), inet_sk(sk)->num);
	return inet_lhashfn(sock_net(sk), inet_sk(sk)->inet_num);
}

/* Caller must disable local BH processing. */
@@ -301,8 +301,8 @@ typedef __u64 __bitwise __addrpair;
#endif /* __BIG_ENDIAN */
#define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\
	(((__sk)->sk_hash == (__hash)) && net_eq(sock_net(__sk), (__net)) &&	\
	 ((*((__addrpair *)&(inet_sk(__sk)->daddr))) == (__cookie))	&&	\
	 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports))	&&	\
	 ((*((__addrpair *)&(inet_sk(__sk)->inet_daddr))) == (__cookie))  &&	\
	 ((*((__portpair *)&(inet_sk(__sk)->inet_dport))) == (__ports))   &&	\
	 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
#define INET_TW_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\
	(((__sk)->sk_hash == (__hash)) && net_eq(sock_net(__sk), (__net)) &&	\
@@ -313,9 +313,9 @@ typedef __u64 __bitwise __addrpair;
#define INET_ADDR_COOKIE(__name, __saddr, __daddr)
#define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)	\
	(((__sk)->sk_hash == (__hash)) && net_eq(sock_net(__sk), (__net))	&&	\
	 (inet_sk(__sk)->daddr		== (__saddr))		&&	\
	 (inet_sk(__sk)->rcv_saddr	== (__daddr))		&&	\
	 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports))	&&	\
	 (inet_sk(__sk)->inet_daddr	== (__saddr))		&&	\
	 (inet_sk(__sk)->inet_rcv_saddr	== (__daddr))		&&	\
	 ((*((__portpair *)&(inet_sk(__sk)->inet_dport))) == (__ports))	&&	\
	 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
#define INET_TW_MATCH(__sk, __net, __hash,__cookie, __saddr, __daddr, __ports, __dif)	\
	(((__sk)->sk_hash == (__hash)) && net_eq(sock_net(__sk), (__net))	&&	\
Loading