1. 06 7月, 2008 20 次提交
  2. 04 7月, 2008 17 次提交
  3. 03 7月, 2008 3 次提交
    • R
      tun: Allow GSO using virtio_net_hdr · f43798c2
      Rusty Russell 提交于
      Add a IFF_VNET_HDR flag.  This uses the same ABI as virtio_net
      (ie. prepending struct virtio_net_hdr to packets) to indicate GSO and
      checksum information.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Acked-by: NMax Krasnyansky <maxk@qualcomm.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f43798c2
    • R
      tun: TUNSETFEATURES to set gso features. · 5228ddc9
      Rusty Russell 提交于
      ethtool is useful for setting (some) device fields, but it's
      root-only.  Finer feature control is available through a tun-specific
      ioctl.
      
      (Includes Mark McLoughlin <markmc@redhat.com>'s fix to hold rtnl sem).
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Acked-by: NMax Krasnyansky <maxk@qualcomm.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5228ddc9
    • R
      tun: Interface to query tun/tap features. · 07240fd0
      Rusty Russell 提交于
      The problem with introducing checksum offload and gso to tun is they
      need to set dev->features to enable GSO and/or checksumming, which is
      supposed to be done before register_netdevice(), ie. as part of
      TUNSETIFF.
      
      Unfortunately, TUNSETIFF has always just ignored flags it doesn't
      understand, so there's no good way of detecting whether the kernel
      supports new IFF_ flags.
      
      This patch implements a TUNGETFEATURES ioctl which returns all the valid IFF
      flags.  It could be extended later to include other features.
      
      Here's an example program which uses it:
      
      #include <linux/if_tun.h>
      #include <sys/types.h>
      #include <sys/ioctl.h>
      #include <sys/stat.h>
      #include <fcntl.h>
      #include <err.h>
      #include <stdio.h>
      
      static struct {
      	unsigned int flag;
      	const char *name;
      } known_flags[] = {
      	{ IFF_TUN, "TUN" },
      	{ IFF_TAP, "TAP" },
      	{ IFF_NO_PI, "NO_PI" },
      	{ IFF_ONE_QUEUE, "ONE_QUEUE" },
      };
      
      int main()
      {
      	unsigned int features, i;
      
      	int netfd = open("/dev/net/tun", O_RDWR);
      	if (netfd < 0)
      		err(1, "Opening /dev/net/tun");
      
      	if (ioctl(netfd, TUNGETFEATURES, &features) != 0) {
      		printf("Kernel does not support TUNGETFEATURES, guessing\n");
      		features = (IFF_TUN|IFF_TAP|IFF_NO_PI|IFF_ONE_QUEUE);
      	}
      	printf("Available features are: ");
      	for (i = 0; i < sizeof(known_flags)/sizeof(known_flags[0]); i++) {
      		if (features & known_flags[i].flag) {
      			features &= ~known_flags[i].flag;
      			printf("%s ", known_flags[i].name);
      		}
      	}
      	if (features)
      		printf("(UNKNOWN %#x)", features);
      	printf("\n");
      	return 0;
      }
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Acked-by: NMax Krasnyansky <maxk@qualcomm.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      07240fd0