diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-05-21 17:17:33 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-05-21 17:43:45 -0400 |
commit | cf3677ae19c2f62979b39143f5d2f6b3dfb3b3e4 (patch) | |
tree | 120eb674a16e922e9bb95bf63af40d6432d79dcb /net/ipv4/ipmr.c | |
parent | 3dca02af38c11a970160387ab36ae6043feb03cd (diff) |
ipmr: Use on-device stats instead of private ones.
These devices use the private area of appropriate size for
statistics. Turning them to use on-device ones make them
"privless" and thus - really small wrt kmalloc cache, they
are allocated from.
Besides, code looks nicer, because of absence of multi-braced
type casts and dereferences.
[ Fix build failures -DaveM ]
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ipmr.c')
-rw-r--r-- | net/ipv4/ipmr.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 65f12005785e..a34da4977c73 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c | |||
@@ -181,26 +181,20 @@ static int reg_vif_num = -1; | |||
181 | static int reg_vif_xmit(struct sk_buff *skb, struct net_device *dev) | 181 | static int reg_vif_xmit(struct sk_buff *skb, struct net_device *dev) |
182 | { | 182 | { |
183 | read_lock(&mrt_lock); | 183 | read_lock(&mrt_lock); |
184 | ((struct net_device_stats*)netdev_priv(dev))->tx_bytes += skb->len; | 184 | dev->stats.tx_bytes += skb->len; |
185 | ((struct net_device_stats*)netdev_priv(dev))->tx_packets++; | 185 | dev->stats.tx_packets++; |
186 | ipmr_cache_report(skb, reg_vif_num, IGMPMSG_WHOLEPKT); | 186 | ipmr_cache_report(skb, reg_vif_num, IGMPMSG_WHOLEPKT); |
187 | read_unlock(&mrt_lock); | 187 | read_unlock(&mrt_lock); |
188 | kfree_skb(skb); | 188 | kfree_skb(skb); |
189 | return 0; | 189 | return 0; |
190 | } | 190 | } |
191 | 191 | ||
192 | static struct net_device_stats *reg_vif_get_stats(struct net_device *dev) | ||
193 | { | ||
194 | return (struct net_device_stats*)netdev_priv(dev); | ||
195 | } | ||
196 | |||
197 | static void reg_vif_setup(struct net_device *dev) | 192 | static void reg_vif_setup(struct net_device *dev) |
198 | { | 193 | { |
199 | dev->type = ARPHRD_PIMREG; | 194 | dev->type = ARPHRD_PIMREG; |
200 | dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr) - 8; | 195 | dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr) - 8; |
201 | dev->flags = IFF_NOARP; | 196 | dev->flags = IFF_NOARP; |
202 | dev->hard_start_xmit = reg_vif_xmit; | 197 | dev->hard_start_xmit = reg_vif_xmit; |
203 | dev->get_stats = reg_vif_get_stats; | ||
204 | dev->destructor = free_netdev; | 198 | dev->destructor = free_netdev; |
205 | } | 199 | } |
206 | 200 | ||
@@ -209,8 +203,7 @@ static struct net_device *ipmr_reg_vif(void) | |||
209 | struct net_device *dev; | 203 | struct net_device *dev; |
210 | struct in_device *in_dev; | 204 | struct in_device *in_dev; |
211 | 205 | ||
212 | dev = alloc_netdev(sizeof(struct net_device_stats), "pimreg", | 206 | dev = alloc_netdev(0, "pimreg", reg_vif_setup); |
213 | reg_vif_setup); | ||
214 | 207 | ||
215 | if (dev == NULL) | 208 | if (dev == NULL) |
216 | return NULL; | 209 | return NULL; |
@@ -1170,8 +1163,8 @@ static void ipmr_queue_xmit(struct sk_buff *skb, struct mfc_cache *c, int vifi) | |||
1170 | if (vif->flags & VIFF_REGISTER) { | 1163 | if (vif->flags & VIFF_REGISTER) { |
1171 | vif->pkt_out++; | 1164 | vif->pkt_out++; |
1172 | vif->bytes_out+=skb->len; | 1165 | vif->bytes_out+=skb->len; |
1173 | ((struct net_device_stats*)netdev_priv(vif->dev))->tx_bytes += skb->len; | 1166 | vif->dev->stats.tx_bytes += skb->len; |
1174 | ((struct net_device_stats*)netdev_priv(vif->dev))->tx_packets++; | 1167 | vif->dev->stats.tx_packets++; |
1175 | ipmr_cache_report(skb, vifi, IGMPMSG_WHOLEPKT); | 1168 | ipmr_cache_report(skb, vifi, IGMPMSG_WHOLEPKT); |
1176 | kfree_skb(skb); | 1169 | kfree_skb(skb); |
1177 | return; | 1170 | return; |
@@ -1487,8 +1480,8 @@ int pim_rcv_v1(struct sk_buff * skb) | |||
1487 | skb->pkt_type = PACKET_HOST; | 1480 | skb->pkt_type = PACKET_HOST; |
1488 | dst_release(skb->dst); | 1481 | dst_release(skb->dst); |
1489 | skb->dst = NULL; | 1482 | skb->dst = NULL; |
1490 | ((struct net_device_stats*)netdev_priv(reg_dev))->rx_bytes += skb->len; | 1483 | reg_dev->stats.rx_bytes += skb->len; |
1491 | ((struct net_device_stats*)netdev_priv(reg_dev))->rx_packets++; | 1484 | reg_dev->stats.rx_packets++; |
1492 | nf_reset(skb); | 1485 | nf_reset(skb); |
1493 | netif_rx(skb); | 1486 | netif_rx(skb); |
1494 | dev_put(reg_dev); | 1487 | dev_put(reg_dev); |
@@ -1542,8 +1535,8 @@ static int pim_rcv(struct sk_buff * skb) | |||
1542 | skb->ip_summed = 0; | 1535 | skb->ip_summed = 0; |
1543 | skb->pkt_type = PACKET_HOST; | 1536 | skb->pkt_type = PACKET_HOST; |
1544 | dst_release(skb->dst); | 1537 | dst_release(skb->dst); |
1545 | ((struct net_device_stats*)netdev_priv(reg_dev))->rx_bytes += skb->len; | 1538 | reg_dev->stats.rx_bytes += skb->len; |
1546 | ((struct net_device_stats*)netdev_priv(reg_dev))->rx_packets++; | 1539 | reg_dev->stats.rx_packets++; |
1547 | skb->dst = NULL; | 1540 | skb->dst = NULL; |
1548 | nf_reset(skb); | 1541 | nf_reset(skb); |
1549 | netif_rx(skb); | 1542 | netif_rx(skb); |