Skip to content

Commit

Permalink
netns: make udpv6 mib per/namespace
Browse files Browse the repository at this point in the history
Signed-off-by: Denis V. Lunev <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Denis V. Lunev authored and davem330 committed Oct 7, 2008
1 parent e43291c commit 0c7ed67
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
1 change: 1 addition & 0 deletions include/net/netns/mib.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct netns_mib {

#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
struct proc_dir_entry *proc_net_devsnmp6;
DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6);
#endif
};

Expand Down
12 changes: 6 additions & 6 deletions include/net/udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ extern struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
__be32 daddr, __be16 dport,
int dif);

DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);

/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);

Expand All @@ -167,12 +165,14 @@ DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
if (is_udplite) SNMP_INC_STATS_BH((net)->mib.udplite_statistics, field); \
else SNMP_INC_STATS_BH((net)->mib.udp_statistics, field); } while(0)

#define UDP6_INC_STATS_BH(net, field, is_udplite) do { (void)net; \
#define UDP6_INC_STATS_BH(net, field, is_udplite) do { \
if (is_udplite) SNMP_INC_STATS_BH(udplite_stats_in6, field); \
else SNMP_INC_STATS_BH(udp_stats_in6, field); } while(0)
#define UDP6_INC_STATS_USER(net, field, is_udplite) do { (void)net; \
else SNMP_INC_STATS_BH((net)->mib.udp_stats_in6, field); \
} while(0)
#define UDP6_INC_STATS_USER(net, field, is_udplite) do { \
if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, field); \
else SNMP_INC_STATS_USER(udp_stats_in6, field); } while(0)
else SNMP_INC_STATS_USER((net)->mib.udp_stats_in6, field); \
} while(0)

#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
#define UDPX_INC_STATS_BH(sk, field) \
Expand Down
3 changes: 0 additions & 3 deletions net/ipv4/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@
* Snmp MIB for the UDP layer
*/

DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
EXPORT_SYMBOL(udp_stats_in6);

struct hlist_head udp_hash[UDP_HTABLE_SIZE];
DEFINE_RWLOCK(udp_hash_lock);

Expand Down
9 changes: 4 additions & 5 deletions net/ipv6/af_inet6.c
Original file line number Diff line number Diff line change
Expand Up @@ -806,16 +806,12 @@ static int __init init_ipv6_mibs(void)
if (snmp_mib_init((void **)icmpv6msg_statistics,
sizeof(struct icmpv6msg_mib)) < 0)
goto err_icmpmsg_mib;
if (snmp_mib_init((void **)udp_stats_in6, sizeof (struct udp_mib)) < 0)
goto err_udp_mib;
if (snmp_mib_init((void **)udplite_stats_in6,
sizeof (struct udp_mib)) < 0)
goto err_udplite_mib;
return 0;

err_udplite_mib:
snmp_mib_free((void **)udp_stats_in6);
err_udp_mib:
snmp_mib_free((void **)icmpv6msg_statistics);
err_icmpmsg_mib:
snmp_mib_free((void **)icmpv6_statistics);
Expand All @@ -831,17 +827,20 @@ static void cleanup_ipv6_mibs(void)
snmp_mib_free((void **)ipv6_statistics);
snmp_mib_free((void **)icmpv6_statistics);
snmp_mib_free((void **)icmpv6msg_statistics);
snmp_mib_free((void **)udp_stats_in6);
snmp_mib_free((void **)udplite_stats_in6);
}

static int __net_init ipv6_init_mibs(struct net *net)
{
if (snmp_mib_init((void **)net->mib.udp_stats_in6,
sizeof (struct udp_mib)) < 0)
return -ENOMEM;
return 0;
}

static void __net_exit ipv6_cleanup_mibs(struct net *net)
{
snmp_mib_free((void **)net->mib.udp_stats_in6);
}

static int inet6_net_init(struct net *net)
Expand Down
3 changes: 2 additions & 1 deletion net/ipv6/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ static int snmp6_seq_show(struct seq_file *seq, void *v)
snmp6_seq_show_item(seq, (void **)ipv6_statistics, snmp6_ipstats_list);
snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list);
snmp6_seq_show_icmpv6msg(seq, (void **)icmpv6msg_statistics);
snmp6_seq_show_item(seq, (void **)udp_stats_in6, snmp6_udp6_list);
snmp6_seq_show_item(seq, (void **)net->mib.udp_stats_in6,
snmp6_udp6_list);
snmp6_seq_show_item(seq, (void **)udplite_stats_in6, snmp6_udplite6_list);
return 0;
}
Expand Down

0 comments on commit 0c7ed67

Please sign in to comment.