Commit ca6b8bb097c8e0ab6bce4fa04584074dee17c0d9

Authored by David S. Miller
1 parent 0033d5ad27

net: Support compat SIOCGETVIFCNT ioctl in ipv4.

Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 30 additions and 0 deletions Side-by-side Diff

... ... @@ -1444,9 +1444,19 @@
1444 1444 compat_ulong_t wrong_if;
1445 1445 };
1446 1446  
  1447 +struct compat_sioc_vif_req {
  1448 + vifi_t vifi; /* Which iface */
  1449 + compat_ulong_t icount;
  1450 + compat_ulong_t ocount;
  1451 + compat_ulong_t ibytes;
  1452 + compat_ulong_t obytes;
  1453 +};
  1454 +
1447 1455 int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg)
1448 1456 {
1449 1457 struct compat_sioc_sg_req sr;
  1458 + struct compat_sioc_vif_req vr;
  1459 + struct vif_device *vif;
1450 1460 struct mfc_cache *c;
1451 1461 struct net *net = sock_net(sk);
1452 1462 struct mr_table *mrt;
... ... @@ -1456,6 +1466,26 @@
1456 1466 return -ENOENT;
1457 1467  
1458 1468 switch (cmd) {
  1469 + case SIOCGETVIFCNT:
  1470 + if (copy_from_user(&vr, arg, sizeof(vr)))
  1471 + return -EFAULT;
  1472 + if (vr.vifi >= mrt->maxvif)
  1473 + return -EINVAL;
  1474 + read_lock(&mrt_lock);
  1475 + vif = &mrt->vif_table[vr.vifi];
  1476 + if (VIF_EXISTS(mrt, vr.vifi)) {
  1477 + vr.icount = vif->pkt_in;
  1478 + vr.ocount = vif->pkt_out;
  1479 + vr.ibytes = vif->bytes_in;
  1480 + vr.obytes = vif->bytes_out;
  1481 + read_unlock(&mrt_lock);
  1482 +
  1483 + if (copy_to_user(arg, &vr, sizeof(vr)))
  1484 + return -EFAULT;
  1485 + return 0;
  1486 + }
  1487 + read_unlock(&mrt_lock);
  1488 + return -EADDRNOTAVAIL;
1459 1489 case SIOCGETSGCNT:
1460 1490 if (copy_from_user(&sr, arg, sizeof(sr)))
1461 1491 return -EFAULT;