Skip to content

Commit f2bf415

Browse files
xemuldavem330
authored andcommitted
mib: add net to NET_ADD_STATS_BH
This one is tricky. The thing is that this macro is only used when killing tw buckets, but since this killer is promiscuous wrt to which net each particular tw belongs to, I have to use it only when NET_NS is off. When the net namespaces are on, I use the INET_INC_STATS_BH for each bucket. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 6f67c81 commit f2bf415

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

include/net/ip.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ DECLARE_SNMP_STAT(struct linux_mib, net_statistics);
164164
#define NET_INC_STATS(net, field) do { (void)net; SNMP_INC_STATS(net_statistics, field); } while (0)
165165
#define NET_INC_STATS_BH(net, field) do { (void)net; SNMP_INC_STATS_BH(net_statistics, field); } while (0)
166166
#define NET_INC_STATS_USER(net, field) do { (void)net; SNMP_INC_STATS_USER(net_statistics, field); } while (0)
167-
#define NET_ADD_STATS_BH(field, adnd) SNMP_ADD_STATS_BH(net_statistics, field, adnd)
167+
#define NET_ADD_STATS_BH(net, field, adnd) do { (void)net; SNMP_ADD_STATS_BH(net_statistics, field, adnd); } while (0)
168168
#define NET_ADD_STATS_USER(field, adnd) SNMP_ADD_STATS_USER(net_statistics, field, adnd)
169169

170170
extern unsigned long snmp_fold_field(void *mib[], int offt);

net/ipv4/inet_timewait_sock.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ static int inet_twdr_do_twkill_work(struct inet_timewait_death_row *twdr,
160160
__inet_twsk_del_dead_node(tw);
161161
spin_unlock(&twdr->death_lock);
162162
__inet_twsk_kill(tw, twdr->hashinfo);
163+
#ifdef CONFIG_NET_NS
164+
NET_INC_STATS_BH(twsk_net(tw), LINUX_MIB_TIMEWAITED);
165+
#endif
163166
inet_twsk_put(tw);
164167
killed++;
165168
spin_lock(&twdr->death_lock);
@@ -178,8 +181,9 @@ static int inet_twdr_do_twkill_work(struct inet_timewait_death_row *twdr,
178181
}
179182

180183
twdr->tw_count -= killed;
181-
NET_ADD_STATS_BH(LINUX_MIB_TIMEWAITED, killed);
182-
184+
#ifndef CONFIG_NET_NS
185+
NET_ADD_STATS_BH(&init_net, LINUX_MIB_TIMEWAITED, killed);
186+
#endif
183187
return ret;
184188
}
185189

@@ -372,6 +376,9 @@ void inet_twdr_twcal_tick(unsigned long data)
372376
&twdr->twcal_row[slot]) {
373377
__inet_twsk_del_dead_node(tw);
374378
__inet_twsk_kill(tw, twdr->hashinfo);
379+
#ifdef CONFIG_NET_NS
380+
NET_INC_STATS_BH(twsk_net(tw), LINUX_MIB_TIMEWAITKILLED);
381+
#endif
375382
inet_twsk_put(tw);
376383
killed++;
377384
}
@@ -395,7 +402,9 @@ void inet_twdr_twcal_tick(unsigned long data)
395402
out:
396403
if ((twdr->tw_count -= killed) == 0)
397404
del_timer(&twdr->tw_timer);
398-
NET_ADD_STATS_BH(LINUX_MIB_TIMEWAITKILLED, killed);
405+
#ifndef CONFIG_NET_NS
406+
NET_ADD_STATS_BH(&init_net, LINUX_MIB_TIMEWAITKILLED, killed);
407+
#endif
399408
spin_unlock(&twdr->death_lock);
400409
}
401410

0 commit comments

Comments
 (0)