Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fb64c735 authored by Chas Williams's avatar Chas Williams Committed by David S. Miller
Browse files

[ATM]: [br2864] whitespace cleanup

parent 097b19a9
Loading
Loading
Loading
Loading
+21 −22
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@
#define BR2684_PAYLOAD_ROUTED   (0)
#define BR2684_PAYLOAD_BRIDGED  (1)


/*
 * This is for the ATM_NEWBACKENDIF call - these are like socket families:
 * the first element of the structure is the backend number and the rest
+114 −108
Original line number Diff line number Diff line
/*
Ethernet netdevice using ATM AAL5 as underlying carrier
(RFC1483 obsoleted by RFC2684) for Linux
Authors: Marcell GAL, 2000, XDSL Ltd, Hungary
         Eric Kinzie, 2006-2007, US Naval Research Laboratory
 * Ethernet netdevice using ATM AAL5 as underlying carrier
 * (RFC1483 obsoleted by RFC2684) for Linux
 *
 * Authors: Marcell GAL, 2000, XDSL Ltd, Hungary
 *          Eric Kinzie, 2006-2007, US Naval Research Laboratory
 */

#include <linux/module.h>
@@ -51,16 +52,12 @@ static void skb_debug(const struct sk_buff *skb)
#define ETHERTYPE_IPV6	0x86, 0xdd
#define PAD_BRIDGED	0x00, 0x00

static unsigned char ethertype_ipv4[] =
	{ ETHERTYPE_IPV4 };
static unsigned char ethertype_ipv6[] =
	{ ETHERTYPE_IPV6 };
static unsigned char ethertype_ipv4[] = { ETHERTYPE_IPV4 };
static unsigned char ethertype_ipv6[] = { ETHERTYPE_IPV6 };
static unsigned char llc_oui_pid_pad[] =
			{ LLC, SNAP_BRIDGED, PID_ETHERNET, PAD_BRIDGED };
static unsigned char llc_oui_ipv4[] =
	{ LLC, SNAP_ROUTED, ETHERTYPE_IPV4 };
static unsigned char llc_oui_ipv6[] =
	{ LLC, SNAP_ROUTED, ETHERTYPE_IPV6 };
static unsigned char llc_oui_ipv4[] = { LLC, SNAP_ROUTED, ETHERTYPE_IPV4 };
static unsigned char llc_oui_ipv6[] = { LLC, SNAP_ROUTED, ETHERTYPE_IPV6 };

enum br2684_encaps {
	e_vc = BR2684_ENCAPS_VC,
@@ -171,17 +168,20 @@ static int br2684_xmit_vcc(struct sk_buff *skb, struct br2684_dev *brdev,
	if (brvcc->encaps == e_llc) {
		if (brdev->payload == p_bridged) {
			skb_push(skb, sizeof(llc_oui_pid_pad));
			skb_copy_to_linear_data(skb, llc_oui_pid_pad, sizeof(llc_oui_pid_pad));
			skb_copy_to_linear_data(skb, llc_oui_pid_pad,
						sizeof(llc_oui_pid_pad));
		} else if (brdev->payload == p_routed) {
			unsigned short prot = ntohs(skb->protocol);

			skb_push(skb, sizeof(llc_oui_ipv4));
			switch (prot) {
			case ETH_P_IP:
					skb_copy_to_linear_data(skb, llc_oui_ipv4, sizeof(llc_oui_ipv4));
				skb_copy_to_linear_data(skb, llc_oui_ipv4,
							sizeof(llc_oui_ipv4));
				break;
			case ETH_P_IPV6:
					skb_copy_to_linear_data(skb, llc_oui_ipv6, sizeof(llc_oui_ipv6));
				skb_copy_to_linear_data(skb, llc_oui_ipv6,
							sizeof(llc_oui_ipv6));
				break;
			default:
				dev_kfree_skb(skb);
@@ -198,9 +198,10 @@ static int br2684_xmit_vcc(struct sk_buff *skb, struct br2684_dev *brdev,
	ATM_SKB(skb)->vcc = atmvcc = brvcc->atmvcc;
	pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, atmvcc->dev);
	if (!atm_may_send(atmvcc, skb->truesize)) {
		/* we free this here for now, because we cannot know in a higher
			layer whether the skb point it supplied wasn't freed yet.
			now, it always is.
		/*
		 * We free this here for now, because we cannot know in a higher
		 * layer whether the skb pointer it supplied wasn't freed yet.
		 * Now, it always is.
		 */
		dev_kfree_skb(skb);
		return 0;
@@ -216,8 +217,7 @@ static int br2684_xmit_vcc(struct sk_buff *skb, struct br2684_dev *brdev,
static inline struct br2684_vcc *pick_outgoing_vcc(struct sk_buff *skb,
						   struct br2684_dev *brdev)
{
	return list_empty(&brdev->brvccs) ? NULL :
	    list_entry_brvcc(brdev->brvccs.next); /* 1 vcc/dev right now */
	return list_empty(&brdev->brvccs) ? NULL : list_entry_brvcc(brdev->brvccs.next);	/* 1 vcc/dev right now */
}

static int br2684_start_xmit(struct sk_buff *skb, struct net_device *dev)
@@ -241,10 +241,9 @@ static int br2684_start_xmit(struct sk_buff *skb, struct net_device *dev)
		/*
		 * We should probably use netif_*_queue() here, but that
		 * involves added complication.  We need to walk before
		 * we can run
		 */
		/* don't free here! this pointer might be no longer valid!
		dev_kfree_skb(skb);
		 * we can run.
		 *
		 * Don't free here! this pointer might be no longer valid!
		 */
		brdev->stats.tx_errors++;
		brdev->stats.tx_fifo_errors++;
@@ -259,7 +258,6 @@ static struct net_device_stats *br2684_get_stats(struct net_device *dev)
	return &BRPRIV(dev)->stats;
}


/*
 * We remember when the MAC gets set, so we don't override it later with
 * the ESI of the ATM card of the first VC
@@ -285,13 +283,12 @@ static int br2684_setfilt(struct atm_vcc *atmvcc, void __user *arg)
	if (fs.ifspec.method != BR2684_FIND_BYNOTHING) {
		/*
		 * This is really a per-vcc thing, but we can also search
		 * by device
		 * by device.
		 */
		struct br2684_dev *brdev;
		read_lock(&devs_lock);
		brdev = BRPRIV(br2684_find_dev(&fs.ifspec));
		if (brdev == NULL || list_empty(&brdev->brvccs) ||
		    brdev->brvccs.next != brdev->brvccs.prev)  /* >1 VCC */
		if (brdev == NULL || list_empty(&brdev->brvccs) || brdev->brvccs.next != brdev->brvccs.prev)	/* >1 VCC */
			brvcc = NULL;
		else
			brvcc = list_entry_brvcc(brdev->brvccs.next);
@@ -316,7 +313,8 @@ packet_fails_filter(__be16 type, struct br2684_vcc *brvcc, struct sk_buff *skb)
		return 0;
	if (type == htons(ETH_P_ARP))
		return 0;
	/* TODO: we should probably filter ARPs too.. don't want to have
	/*
	 * TODO: we should probably filter ARPs too.. don't want to have
	 * them returning values that don't make sense, or is that ok?
	 */
	return 1;		/* drop */
@@ -367,10 +365,17 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb)

		/* accept packets that have "ipv[46]" in the snap header */
		if ((skb->len >= (sizeof(llc_oui_ipv4)))
		    && (memcmp(skb->data, llc_oui_ipv4, sizeof(llc_oui_ipv4) - BR2684_ETHERTYPE_LEN) == 0)) {
			if (memcmp(skb->data + 6, ethertype_ipv6, sizeof(ethertype_ipv6)) == 0)
		    &&
		    (memcmp
		     (skb->data, llc_oui_ipv4,
		      sizeof(llc_oui_ipv4) - BR2684_ETHERTYPE_LEN) == 0)) {
			if (memcmp
			    (skb->data + 6, ethertype_ipv6,
			     sizeof(ethertype_ipv6)) == 0)
				skb->protocol = __constant_htons(ETH_P_IPV6);
			else if (memcmp(skb->data + 6, ethertype_ipv4, sizeof(ethertype_ipv4)) == 0)
			else if (memcmp
				 (skb->data + 6, ethertype_ipv4,
				  sizeof(ethertype_ipv4)) == 0)
				skb->protocol = __constant_htons(ETH_P_IP);
			else {
				brdev->stats.rx_errors++;
@@ -380,10 +385,11 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb)
			skb_pull(skb, sizeof(llc_oui_ipv4));
			skb_reset_network_header(skb);
			skb->pkt_type = PACKET_HOST;

		/* let us waste some time for checking the encapsulation.
		   Note, that only 7 char is checked so frames with a valid FCS
		   are also accepted (but FCS is not checked of course) */
			/*
			 * Let us waste some time for checking the encapsulation.
			 * Note, that only 7 char is checked so frames with a valid FCS
			 * are also accepted (but FCS is not checked of course).
			 */
		} else if ((skb->len >= sizeof(llc_oui_pid_pad)) &&
			   (memcmp(skb->data, llc_oui_pid_pad, 7) == 0)) {
			skb_pull(skb, sizeof(llc_oui_pid_pad));
@@ -428,11 +434,12 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb)
	netif_rx(skb);
}

/*
 * Assign a vcc to a dev
 * Note: we do not have explicit unassign, but look at _push()
 */
static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)
{
/* assign a vcc to a dev
Note: we do not have explicit unassign, but look at _push()
*/
	int err;
	struct br2684_vcc *brvcc;
	struct sk_buff *skb;
@@ -467,13 +474,15 @@ Note: we do not have explicit unassign, but look at _push()
	}
	if (be.fcs_in != BR2684_FCSIN_NO || be.fcs_out != BR2684_FCSOUT_NO ||
	    be.fcs_auto || be.has_vpiid || be.send_padding || (be.encaps !=
	    BR2684_ENCAPS_VC && be.encaps != BR2684_ENCAPS_LLC) ||
	    be.min_size != 0) {
							       BR2684_ENCAPS_VC
							       && be.encaps !=
							       BR2684_ENCAPS_LLC)
	    || be.min_size != 0) {
		err = -EINVAL;
		goto error;
	}
	pr_debug("br2684_regvcc vcc=%p, encaps=%d, brvcc=%p\n", atmvcc, be.encaps,
		brvcc);
	pr_debug("br2684_regvcc vcc=%p, encaps=%d, brvcc=%p\n", atmvcc,
		 be.encaps, brvcc);
	if (list_empty(&brdev->brvccs) && !brdev->mac_was_set) {
		unsigned char *esi = atmvcc->dev->esi;
		if (esi[0] | esi[1] | esi[2] | esi[3] | esi[4] | esi[5])
@@ -616,12 +625,12 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd,
{
	struct atm_vcc *atmvcc = ATM_SD(sock);
	void __user *argp = (void __user *)arg;
	atm_backend_t b;

	int err;
	switch (cmd) {
	case ATM_SETBACKEND:
	case ATM_NEWBACKENDIF: {
		atm_backend_t b;
	case ATM_NEWBACKENDIF:
		err = get_user(b, (atm_backend_t __user *) argp);
		if (err)
			return -EFAULT;
@@ -633,7 +642,6 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd,
			return br2684_regvcc(atmvcc, argp);
		else
			return br2684_create(argp);
		}
#ifdef CONFIG_ATM_BR2684_IPFILTER
	case BR2684_SETFILT:
		if (atmvcc->push != br2684_push)
@@ -641,6 +649,7 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd,
		if (!capable(CAP_NET_ADMIN))
			return -EPERM;
		err = br2684_setfilt(atmvcc, argp);

		return err;
#endif /* CONFIG_ATM_BR2684_IPFILTER */
	}
@@ -652,7 +661,6 @@ static struct atm_ioctl br2684_ioctl_ops = {
	.ioctl = br2684_ioctl,
};


#ifdef CONFIG_PROC_FS
static void *br2684_seq_start(struct seq_file *seq, loff_t * pos)
{
@@ -691,15 +699,13 @@ static int br2684_seq_show(struct seq_file *seq, void *v)
			   brvcc->atmvcc->vpi, brvcc->atmvcc->vci,
			   (brvcc->encaps == e_llc) ? "LLC" : "VC",
			   (brdev->payload == p_bridged) ? "bridged" : "routed",
				      brvcc->copies_failed,
				      brvcc->copies_needed);
			   brvcc->copies_failed, brvcc->copies_needed);
#ifdef CONFIG_ATM_BR2684_IPFILTER
#define b1(var, byte)	((u8 *) &brvcc->filter.var)[byte]
#define bs(var)		b1(var, 0), b1(var, 1), b1(var, 2), b1(var, 3)
		if (brvcc->filter.netmask != 0)
			seq_printf(seq, "    filter=%d.%d.%d.%d/"
						"%d.%d.%d.%d\n",
						bs(prefix), bs(netmask));
				   "%d.%d.%d.%d\n", bs(prefix), bs(netmask));
#undef bs
#undef b1
#endif /* CONFIG_ATM_BR2684_IPFILTER */
@@ -728,7 +734,7 @@ static const struct file_operations br2684_proc_ops = {
};

extern struct proc_dir_entry *atm_proc_root;	/* from proc.c */
#endif
#endif /* CONFIG_PROC_FS */

static int __init br2684_init(void)
{