netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Shaun Jackman <sjackman@gmail.com>
Cc: netdev@oss.sgi.com
Subject: Re: Multicast filtering for tun.c [PATCH]
Date: Wed, 1 Dec 2004 23:34:00 -0800	[thread overview]
Message-ID: <20041201233400.45078efe.akpm@osdl.org> (raw)
In-Reply-To: <7f45d939041201140329d0273f@mail.gmail.com>

Shaun Jackman <sjackman@gmail.com> wrote:
>
> This patch adds multicast filtering to the TUN network driver, for
> packets being sent from the network device to the character device. It
> applies against the 2.6.8.1 kernel tree.
> 
> ...

Minor points:


> diff -ur linux-2.6.8.1.orig/drivers/net/tun.c linux-2.6.8.1/drivers/net/tun.c
> --- linux-2.6.8.1.orig/drivers/net/tun.c	2004-08-14 03:55:23.000000000 -0700
> +++ linux-2.6.8.1/drivers/net/tun.c	2004-11-25 17:00:22.000000000 -0800
> @@ -41,6 +41,7 @@
>  #include <linux/if_arp.h>
>  #include <linux/if_ether.h>
>  #include <linux/if_tun.h>
> +#include <linux/crc32.h>

You're sure this shouldn't be using crc-ccitt?

> +del_multi(u32* filter, const u8* addr)

	del_multi(u32 *filter, const u8 *addr)

would be a more typical layout.

>  static struct net_device_stats *tun_net_stats(struct net_device *dev)
> @@ -301,6 +333,10 @@
>  
>  	add_wait_queue(&tun->read_wait, &wait);
>  	while (len) {
> +		const u8 ones[ ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };

The space after the `[' is gratuitous.

This array will be allocated onthe stack and populated by hand each time
this function is called.   It should be made static.

> +		u8 addr[ ETH_ALEN];

extraneous space.

> +		memcpy(addr, skb->data, min(sizeof addr, skb->len));

We normally put parentheses around the argument of the sizeof operator, for
no particular reason ;)

> +		if (copy_from_user(&ifr, argp, sizeof ifr))

Ditto

> +	case SIOCGIFFLAGS:
> +		ifr.ifr_flags = tun->if_flags;
> +		if (copy_to_user( argp, &ifr, sizeof ifr))

extraneous space.

> +		if (copy_to_user( argp, &ifr, sizeof ifr))

ditto

> +		DBG(KERN_DEBUG "%s: add multi: %x:%x:%x:%x:%x:%x\n",
> +				tun->dev->name,
> +				(u8)ifr.ifr_hwaddr.sa_data[0], (u8)ifr.ifr_hwaddr.sa_data[1],
> +				(u8)ifr.ifr_hwaddr.sa_data[2], (u8)ifr.ifr_hwaddr.sa_data[3],
> +				(u8)ifr.ifr_hwaddr.sa_data[4], (u8)ifr.ifr_hwaddr.sa_data[5]);

Why all the typecasts?

> +	case SIOCDELMULTI:
> +		/** Remove the specified group from the character device's multicast
> +		 * filter list. */
> +		del_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data);
> +		DBG(KERN_DEBUG "%s: del multi: %x:%x:%x:%x:%x:%x\n",
> +				tun->dev->name,
> +				(u8)ifr.ifr_hwaddr.sa_data[0], (u8)ifr.ifr_hwaddr.sa_data[1],
> +				(u8)ifr.ifr_hwaddr.sa_data[2], (u8)ifr.ifr_hwaddr.sa_data[3],
> +				(u8)ifr.ifr_hwaddr.sa_data[4], (u8)ifr.ifr_hwaddr.sa_data[5]);

ditto.

  reply	other threads:[~2004-12-02  7:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <7f45d9390411251715138b35d0@mail.gmail.com>
     [not found] ` <20041127011006.03232bb6.akpm@osdl.org>
2004-12-01 22:03   ` Multicast filtering for tun.c [PATCH] Shaun Jackman
2004-12-02  7:34     ` Andrew Morton [this message]
2004-12-02 17:28       ` Shaun Jackman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041201233400.45078efe.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=netdev@oss.sgi.com \
    --cc=sjackman@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).