Skip to contentSkip to conversation

net: some optimizations in af_inet

PATCH Applied Eric Dumazet 2 participants 2 messages Nov 22, 2008 – Nov 23, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: some optimizations in af_inet

1) Use eq_net() in inet_netns_ok() to speedup socket creation if !CONFIG_NET_NS

2) Reorder the tests about inet_ehash_secret generation (once only) Use the unlikely() macro when testing if inet_ehash_secret already generated.

net/ipv4/af_inet.c +4 -5
index b1462e8..fe03048 100644
@@ -245,7 +245,7 @@ static inline int inet_netns_ok(struct net *net, int protocol)
 	int hash;
 	struct net_protocol *ipprot;
 
-	if (net == &init_net)
+	if (net_eq(net, &init_net))
 		return 1;
 
 	hash = protocol & (MAX_INET_PROTOS - 1);
@@ -272,10 +272,9 @@ static int inet_create(struct net *net, struct socket *sock, int protocol)
 	int try_loading_module = 0;
 	int err;
 
-	if (sock->type != SOCK_RAW &&
-	    sock->type != SOCK_DGRAM &&
-	    !inet_ehash_secret)
-		build_ehash_secret();
+	if (unlikely(!inet_ehash_secret))
+		if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM)
+			build_ehash_secret();
 
 	sock->state = SS_UNCONNECTED;
 
maintainer Applied
#1 lore raw

From: Eric Dumazet <[email protected]>
Date: Sat, 22 Nov 2008 08:06:09 +0100

Quoted 6 lines

1) Use eq_net() in inet_netns_ok() to speedup socket creation if !CONFIG_NET_NS

2) Reorder the tests about inet_ehash_secret generation (once only) Use the unlikely() macro when testing if inet_ehash_secret already generated.

Applied, thanks Eric.