aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-25 13:26:21 -0400
committerYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-25 15:39:55 -0400
commit3b1e0a655f8eba44ab1ee2a1068d169ccfb853b9 (patch)
tree09edb35f32ebcfb1b4dad904425128a110ef16ee /net/core
parentc346dca10840a874240c78efe3f39acf4312a1f2 (diff)
[NET] NETNS: Omit sock->sk_net without CONFIG_NET_NS.
Introduce per-sock inlines: sock_net(), sock_net_set() and per-inet_timewait_sock inlines: twsk_net(), twsk_net_set(). Without CONFIG_NET_NS, no namespace other than &init_net exists. Let's explicitly define them to help compiler optimizations. Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/fib_rules.c6
-rw-r--r--net/core/neighbour.c10
-rw-r--r--net/core/rtnetlink.c12
-rw-r--r--net/core/sock.c10
4 files changed, 19 insertions, 19 deletions
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 942be93a2eb0..540c07283e31 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -214,7 +214,7 @@ errout:
214 214
215static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) 215static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
216{ 216{
217 struct net *net = skb->sk->sk_net; 217 struct net *net = sock_net(skb->sk);
218 struct fib_rule_hdr *frh = nlmsg_data(nlh); 218 struct fib_rule_hdr *frh = nlmsg_data(nlh);
219 struct fib_rules_ops *ops = NULL; 219 struct fib_rules_ops *ops = NULL;
220 struct fib_rule *rule, *r, *last = NULL; 220 struct fib_rule *rule, *r, *last = NULL;
@@ -352,7 +352,7 @@ errout:
352 352
353static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) 353static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
354{ 354{
355 struct net *net = skb->sk->sk_net; 355 struct net *net = sock_net(skb->sk);
356 struct fib_rule_hdr *frh = nlmsg_data(nlh); 356 struct fib_rule_hdr *frh = nlmsg_data(nlh);
357 struct fib_rules_ops *ops = NULL; 357 struct fib_rules_ops *ops = NULL;
358 struct fib_rule *rule, *tmp; 358 struct fib_rule *rule, *tmp;
@@ -534,7 +534,7 @@ skip:
534 534
535static int fib_nl_dumprule(struct sk_buff *skb, struct netlink_callback *cb) 535static int fib_nl_dumprule(struct sk_buff *skb, struct netlink_callback *cb)
536{ 536{
537 struct net *net = skb->sk->sk_net; 537 struct net *net = sock_net(skb->sk);
538 struct fib_rules_ops *ops; 538 struct fib_rules_ops *ops;
539 int idx = 0, family; 539 int idx = 0, family;
540 540
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index c978bd1cd659..065fbac7ecd3 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1478,7 +1478,7 @@ int neigh_table_clear(struct neigh_table *tbl)
1478 1478
1479static int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 1479static int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
1480{ 1480{
1481 struct net *net = skb->sk->sk_net; 1481 struct net *net = sock_net(skb->sk);
1482 struct ndmsg *ndm; 1482 struct ndmsg *ndm;
1483 struct nlattr *dst_attr; 1483 struct nlattr *dst_attr;
1484 struct neigh_table *tbl; 1484 struct neigh_table *tbl;
@@ -1544,7 +1544,7 @@ out:
1544 1544
1545static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 1545static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
1546{ 1546{
1547 struct net *net = skb->sk->sk_net; 1547 struct net *net = sock_net(skb->sk);
1548 struct ndmsg *ndm; 1548 struct ndmsg *ndm;
1549 struct nlattr *tb[NDA_MAX+1]; 1549 struct nlattr *tb[NDA_MAX+1];
1550 struct neigh_table *tbl; 1550 struct neigh_table *tbl;
@@ -1812,7 +1812,7 @@ static const struct nla_policy nl_ntbl_parm_policy[NDTPA_MAX+1] = {
1812 1812
1813static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 1813static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
1814{ 1814{
1815 struct net *net = skb->sk->sk_net; 1815 struct net *net = sock_net(skb->sk);
1816 struct neigh_table *tbl; 1816 struct neigh_table *tbl;
1817 struct ndtmsg *ndtmsg; 1817 struct ndtmsg *ndtmsg;
1818 struct nlattr *tb[NDTA_MAX+1]; 1818 struct nlattr *tb[NDTA_MAX+1];
@@ -1937,7 +1937,7 @@ errout:
1937 1937
1938static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb) 1938static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
1939{ 1939{
1940 struct net *net = skb->sk->sk_net; 1940 struct net *net = sock_net(skb->sk);
1941 int family, tidx, nidx = 0; 1941 int family, tidx, nidx = 0;
1942 int tbl_skip = cb->args[0]; 1942 int tbl_skip = cb->args[0];
1943 int neigh_skip = cb->args[1]; 1943 int neigh_skip = cb->args[1];
@@ -2037,7 +2037,7 @@ static void neigh_update_notify(struct neighbour *neigh)
2037static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, 2037static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
2038 struct netlink_callback *cb) 2038 struct netlink_callback *cb)
2039{ 2039{
2040 struct net * net = skb->sk->sk_net; 2040 struct net * net = sock_net(skb->sk);
2041 struct neighbour *n; 2041 struct neighbour *n;
2042 int rc, h, s_h = cb->args[1]; 2042 int rc, h, s_h = cb->args[1];
2043 int idx, s_idx = idx = cb->args[2]; 2043 int idx, s_idx = idx = cb->args[2];
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 09250a0800f6..da99ac0871bf 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -662,7 +662,7 @@ nla_put_failure:
662 662
663static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) 663static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
664{ 664{
665 struct net *net = skb->sk->sk_net; 665 struct net *net = sock_net(skb->sk);
666 int idx; 666 int idx;
667 int s_idx = cb->args[0]; 667 int s_idx = cb->args[0];
668 struct net_device *dev; 668 struct net_device *dev;
@@ -879,7 +879,7 @@ errout:
879 879
880static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 880static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
881{ 881{
882 struct net *net = skb->sk->sk_net; 882 struct net *net = sock_net(skb->sk);
883 struct ifinfomsg *ifm; 883 struct ifinfomsg *ifm;
884 struct net_device *dev; 884 struct net_device *dev;
885 int err; 885 int err;
@@ -921,7 +921,7 @@ errout:
921 921
922static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 922static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
923{ 923{
924 struct net *net = skb->sk->sk_net; 924 struct net *net = sock_net(skb->sk);
925 const struct rtnl_link_ops *ops; 925 const struct rtnl_link_ops *ops;
926 struct net_device *dev; 926 struct net_device *dev;
927 struct ifinfomsg *ifm; 927 struct ifinfomsg *ifm;
@@ -1000,7 +1000,7 @@ err:
1000 1000
1001static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 1001static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
1002{ 1002{
1003 struct net *net = skb->sk->sk_net; 1003 struct net *net = sock_net(skb->sk);
1004 const struct rtnl_link_ops *ops; 1004 const struct rtnl_link_ops *ops;
1005 struct net_device *dev; 1005 struct net_device *dev;
1006 struct ifinfomsg *ifm; 1006 struct ifinfomsg *ifm;
@@ -1132,7 +1132,7 @@ replay:
1132 1132
1133static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) 1133static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
1134{ 1134{
1135 struct net *net = skb->sk->sk_net; 1135 struct net *net = sock_net(skb->sk);
1136 struct ifinfomsg *ifm; 1136 struct ifinfomsg *ifm;
1137 struct nlattr *tb[IFLA_MAX+1]; 1137 struct nlattr *tb[IFLA_MAX+1];
1138 struct net_device *dev = NULL; 1138 struct net_device *dev = NULL;
@@ -1227,7 +1227,7 @@ static int rtattr_max;
1227 1227
1228static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) 1228static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
1229{ 1229{
1230 struct net *net = skb->sk->sk_net; 1230 struct net *net = sock_net(skb->sk);
1231 rtnl_doit_func doit; 1231 rtnl_doit_func doit;
1232 int sz_idx, kind; 1232 int sz_idx, kind;
1233 int min_len; 1233 int min_len;
diff --git a/net/core/sock.c b/net/core/sock.c
index b1a6ed4d33c1..3ee95060dbd0 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -372,7 +372,7 @@ static int sock_bindtodevice(struct sock *sk, char __user *optval, int optlen)
372{ 372{
373 int ret = -ENOPROTOOPT; 373 int ret = -ENOPROTOOPT;
374#ifdef CONFIG_NETDEVICES 374#ifdef CONFIG_NETDEVICES
375 struct net *net = sk->sk_net; 375 struct net *net = sock_net(sk);
376 char devname[IFNAMSIZ]; 376 char devname[IFNAMSIZ];
377 int index; 377 int index;
378 378
@@ -958,7 +958,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
958 */ 958 */
959 sk->sk_prot = sk->sk_prot_creator = prot; 959 sk->sk_prot = sk->sk_prot_creator = prot;
960 sock_lock_init(sk); 960 sock_lock_init(sk);
961 sk->sk_net = get_net(net); 961 sock_net_set(sk, get_net(net));
962 } 962 }
963 963
964 return sk; 964 return sk;
@@ -983,7 +983,7 @@ void sk_free(struct sock *sk)
983 printk(KERN_DEBUG "%s: optmem leakage (%d bytes) detected.\n", 983 printk(KERN_DEBUG "%s: optmem leakage (%d bytes) detected.\n",
984 __func__, atomic_read(&sk->sk_omem_alloc)); 984 __func__, atomic_read(&sk->sk_omem_alloc));
985 985
986 put_net(sk->sk_net); 986 put_net(sock_net(sk));
987 sk_prot_free(sk->sk_prot_creator, sk); 987 sk_prot_free(sk->sk_prot_creator, sk);
988} 988}
989 989
@@ -1001,7 +1001,7 @@ void sk_release_kernel(struct sock *sk)
1001 1001
1002 sock_hold(sk); 1002 sock_hold(sk);
1003 sock_release(sk->sk_socket); 1003 sock_release(sk->sk_socket);
1004 sk->sk_net = get_net(&init_net); 1004 sock_net_set(sk, get_net(&init_net));
1005 sock_put(sk); 1005 sock_put(sk);
1006} 1006}
1007EXPORT_SYMBOL(sk_release_kernel); 1007EXPORT_SYMBOL(sk_release_kernel);
@@ -1017,7 +1017,7 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority)
1017 sock_copy(newsk, sk); 1017 sock_copy(newsk, sk);
1018 1018
1019 /* SANITY */ 1019 /* SANITY */
1020 get_net(newsk->sk_net); 1020 get_net(sock_net(newsk));
1021 sk_node_init(&newsk->sk_node); 1021 sk_node_init(&newsk->sk_node);
1022 sock_lock_init(newsk); 1022 sock_lock_init(newsk);
1023 bh_lock_sock(newsk); 1023 bh_lock_sock(newsk);