diff options
Diffstat (limited to 'net/ipv4/af_inet.c')
-rw-r--r-- | net/ipv4/af_inet.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index a33ca7e7e8f8..16aae8ef5555 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -1219,6 +1219,46 @@ out: | |||
1219 | return segs; | 1219 | return segs; |
1220 | } | 1220 | } |
1221 | 1221 | ||
1222 | unsigned long snmp_fold_field(void *mib[], int offt) | ||
1223 | { | ||
1224 | unsigned long res = 0; | ||
1225 | int i; | ||
1226 | |||
1227 | for_each_possible_cpu(i) { | ||
1228 | res += *(((unsigned long *) per_cpu_ptr(mib[0], i)) + offt); | ||
1229 | res += *(((unsigned long *) per_cpu_ptr(mib[1], i)) + offt); | ||
1230 | } | ||
1231 | return res; | ||
1232 | } | ||
1233 | EXPORT_SYMBOL_GPL(snmp_fold_field); | ||
1234 | |||
1235 | int snmp_mib_init(void *ptr[2], size_t mibsize, size_t mibalign) | ||
1236 | { | ||
1237 | BUG_ON(ptr == NULL); | ||
1238 | ptr[0] = __alloc_percpu(mibsize); | ||
1239 | if (!ptr[0]) | ||
1240 | goto err0; | ||
1241 | ptr[1] = __alloc_percpu(mibsize); | ||
1242 | if (!ptr[1]) | ||
1243 | goto err1; | ||
1244 | return 0; | ||
1245 | err1: | ||
1246 | free_percpu(ptr[0]); | ||
1247 | ptr[0] = NULL; | ||
1248 | err0: | ||
1249 | return -ENOMEM; | ||
1250 | } | ||
1251 | EXPORT_SYMBOL_GPL(snmp_mib_init); | ||
1252 | |||
1253 | void snmp_mib_free(void *ptr[2]) | ||
1254 | { | ||
1255 | BUG_ON(ptr == NULL); | ||
1256 | free_percpu(ptr[0]); | ||
1257 | free_percpu(ptr[1]); | ||
1258 | ptr[0] = ptr[1] = NULL; | ||
1259 | } | ||
1260 | EXPORT_SYMBOL_GPL(snmp_mib_free); | ||
1261 | |||
1222 | #ifdef CONFIG_IP_MULTICAST | 1262 | #ifdef CONFIG_IP_MULTICAST |
1223 | static struct net_protocol igmp_protocol = { | 1263 | static struct net_protocol igmp_protocol = { |
1224 | .handler = igmp_rcv, | 1264 | .handler = igmp_rcv, |