diff options
| author | David S. Miller <davem@nuts.ninka.net> | 2002-07-28 08:54:50 -0700 |
|---|---|---|
| committer | David S. Miller <davem@nuts.ninka.net> | 2002-07-28 08:54:50 -0700 |
| commit | 856d8b52fe04b6870111eaace963ee3ebc692050 (patch) | |
| tree | ac86a9cd9b32a79270abc7d208fa2a49b0cbaa16 | |
| parent | 3f0c2c5bf51916b997219be6e06c2aa61da0b5c7 (diff) | |
| parent | d0c91cb7127b4a086c04257ce827686cb7bbbdb3 (diff) | |
Merge nuts.ninka.net:/home/davem/src/BK/BAK-net-2.5
into nuts.ninka.net:/home/davem/src/BK/net-2.5
77 files changed, 4232 insertions, 2377 deletions
@@ -713,6 +713,11 @@ S: 3000 FORE Drive S: Warrendale, Pennsylvania 15086 S: USA +N: Martin Devera +E: devik@cdi.cz +W: http://luxik.cdi.cz/~devik/qos/ +D: HTB qdisc and random networking hacks + N: Alex deVries E: adevries@thepuffingroup.com D: Various SGI parts, bits of HAL2 and Newport, PA-RISC Linux. diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c index 525e369b2980..f10fc0bc3a68 100644 --- a/drivers/net/sk98lin/skge.c +++ b/drivers/net/sk98lin/skge.c @@ -404,6 +404,7 @@ void proc_fill_inode(struct inode *inode, int fill) */ static int __init skge_probe (void) { + int proc_root_initialized = 0; int boards_found = 0; int version_disp = 0; SK_AC *pAC; @@ -429,11 +430,6 @@ static int __init skge_probe (void) if (!pci_present()) /* is PCI support present? */ return -ENODEV; - pSkRootDir = create_proc_entry("sk98lin", - S_IFDIR | S_IWUSR | S_IRUGO | S_IXUGO, proc_net); - - pSkRootDir->owner = THIS_MODULE; - while((pdev = pci_find_device(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_GE, pdev)) != NULL) { @@ -485,6 +481,14 @@ static int __init skge_probe (void) dev->do_ioctl = &SkGeIoctl; dev->change_mtu = &SkGeChangeMtu; + if(!proc_root_initialized) { + pSkRootDir = create_proc_entry("sk98lin", + S_IFDIR | S_IWUSR | S_IRUGO | S_IXUGO, proc_net); + pSkRootDir->owner = THIS_MODULE; + + proc_root_initialized = 1; + } + pProcFile = create_proc_entry(dev->name, S_IFREG | 0444, pSkRootDir); pProcFile->read_proc = proc_read; diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index d074417a114a..89aed8654dbc 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -52,8 +52,8 @@ #define DRV_MODULE_NAME "tg3" #define PFX DRV_MODULE_NAME ": " -#define DRV_MODULE_VERSION "0.99-NAPI" -#define DRV_MODULE_RELDATE "Jun 20, 2002" +#define DRV_MODULE_VERSION "1.0" +#define DRV_MODULE_RELDATE "Jul 19, 2002" #define TG3_DEF_MAC_MODE 0 #define TG3_DEF_RX_MODE 0 @@ -1922,8 +1922,11 @@ static int tg3_poll(struct net_device *netdev, int *budget) } } - if (sblk->idx[0].tx_consumer != tp->tx_cons) + if (sblk->idx[0].tx_consumer != tp->tx_cons) { + spin_lock(&tp->tx_lock); tg3_tx(tp); + spin_unlock(&tp->tx_lock); + } done = 1; if (sblk->idx[0].rx_producer != tp->rx_rcb_ptr) { @@ -2014,11 +2017,13 @@ static void tg3_tx_timeout(struct net_device *dev) dev->name); spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); tg3_halt(tp); tg3_init_rings(tp); tg3_init_hw(tp); + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); netif_wake_queue(dev); @@ -2203,12 +2208,16 @@ static int tg3_start_xmit_4gbug(struct sk_buff *skb, struct net_device *dev) len = (skb->len - skb->data_len); - spin_lock_irq(&tp->lock); + /* No BH disabling for tx_lock here. We are running in BH disabled + * context and TX reclaim runs via tp->poll inside of a software + * interrupt. Rejoice! + */ + spin_lock(&tp->tx_lock); /* This is a hard error, log it. */ if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) { netif_stop_queue(dev); - spin_unlock_irq(&tp->lock); + spin_unlock(&tp->tx_lock); printk(KERN_ERR PFX "%s: BUG! Tx Ring full when queue awake!\n", dev->name); return 1; @@ -2327,7 +2336,7 @@ static int tg3_start_xmit_4gbug(struct sk_buff *skb, struct net_device *dev) netif_stop_queue(dev); out_unlock: - spin_unlock_irq(&tp->lock); + spin_unlock(&tp->tx_lock); dev->trans_start = jiffies; @@ -2342,12 +2351,16 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev) len = (skb->len - skb->data_len); - spin_lock_irq(&tp->lock); + /* No BH disabling for tx_lock here. We are running in BH disabled + * context and TX reclaim runs via tp->poll inside of a software + * interrupt. Rejoice! + */ + spin_lock(&tp->tx_lock); /* This is a hard error, log it. */ if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) { netif_stop_queue(dev); - spin_unlock_irq(&tp->lock); + spin_unlock(&tp->tx_lock); printk(KERN_ERR PFX "%s: BUG! Tx Ring full when queue awake!\n", dev->name); return 1; @@ -2416,7 +2429,7 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev) if (TX_BUFFS_AVAIL(tp) <= (MAX_SKB_FRAGS + 1)) netif_stop_queue(dev); - spin_unlock_irq(&tp->lock); + spin_unlock(&tp->tx_lock); dev->trans_start = jiffies; @@ -2439,6 +2452,7 @@ static int tg3_change_mtu(struct net_device *dev, int new_mtu) } spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); tg3_halt(tp); @@ -2452,6 +2466,7 @@ static int tg3_change_mtu(struct net_device *dev, int new_mtu) tg3_init_rings(tp); tg3_init_hw(tp); + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); return 0; @@ -2461,7 +2476,7 @@ static int tg3_change_mtu(struct net_device *dev, int new_mtu) * * The chip has been shut down and the driver detached from * the networking, so no interrupts or new tx packets will - * end up in the driver. tp->lock is not held and we are not + * end up in the driver. tp->{tx,}lock is not held and we are not * in an interrupt context and thus may sleep. */ static void tg3_free_rings(struct tg3 *tp) @@ -2546,7 +2561,7 @@ static void tg3_free_rings(struct tg3 *tp) * * The chip has been shut down and the driver detached from * the networking, so no interrupts or new tx packets will - * end up in the driver. tp->lock is not held and we are not + * end up in the driver. tp->{tx,}lock is not held and we are not * in an interrupt context and thus may sleep. */ static void tg3_init_rings(struct tg3 *tp) @@ -3711,6 +3726,7 @@ static void tg3_timer(unsigned long __opaque) struct tg3 *tp = (struct tg3 *) __opaque; spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); /* All of this garbage is because when using non-tagged * IRQ status the mailbox/status_block protocol the chip @@ -3772,6 +3788,7 @@ static void tg3_timer(unsigned long __opaque) tp->timer_counter = tp->timer_multiplier; } + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); tp->timer.expires = jiffies + tp->timer_offset; @@ -3784,10 +3801,12 @@ static int tg3_open(struct net_device *dev) int err; spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); tg3_disable_ints(tp); tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE; + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); /* If you move this call, make sure TG3_FLAG_HOST_TXDS in @@ -3806,6 +3825,7 @@ static int tg3_open(struct net_device *dev) } spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); tg3_init_rings(tp); @@ -3823,13 +3843,10 @@ static int tg3_open(struct net_device *dev) tp->timer.function = tg3_timer; add_timer(&tp->timer); - tp->last_rate_sample = jiffies; - tp->last_rx_count = 0; - tp->last_tx_count = 0; - tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE; } + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); if (err) { @@ -3841,9 +3858,11 @@ static int tg3_open(struct net_device *dev) netif_start_queue(dev); spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); tg3_enable_ints(tp); + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); return 0; @@ -4105,6 +4124,7 @@ static int tg3_close(struct net_device *dev) del_timer_sync(&tp->timer); spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); #if 0 tg3_dump_state(tp); #endif @@ -4118,6 +4138,7 @@ static int tg3_close(struct net_device *dev) TG3_FLAG_GOT_SERDES_FLOWCTL); netif_carrier_off(tp->dev); + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); free_irq(dev->irq, dev); @@ -4325,6 +4346,7 @@ static u8 *tg3_get_regs(struct tg3 *tp) memset(orig_p, 0, TG3_REGDUMP_LEN); spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); #define __GET_REG32(reg) (*((u32 *)(p))++ = tr32(reg)) #define GET_REG32_LOOP(base,len) \ @@ -4373,6 +4395,7 @@ do { p = orig_p + (reg); \ #undef GET_REG32_LOOP #undef GET_REG32_1 + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); return orig_p; @@ -4471,6 +4494,7 @@ static int tg3_ethtool_ioctl (struct net_device *dev, void *useraddr) } spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); tp->link_config.autoneg = cmd.autoneg; if (cmd.autoneg == AUTONEG_ENABLE) { @@ -4483,6 +4507,7 @@ static int tg3_ethtool_ioctl (struct net_device *dev, void *useraddr) } tg3_setup_phy(tp); + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); return 0; @@ -4617,6 +4642,7 @@ static int tg3_ethtool_ioctl (struct net_device *dev, void *useraddr) return -EINVAL; spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); tp->rx_pending = ering.rx_pending; #if TG3_MINI_RING_WORKS @@ -4629,6 +4655,7 @@ static int tg3_ethtool_ioctl (struct net_device *dev, void *useraddr) tg3_init_rings(tp); tg3_init_hw(tp); netif_wake_queue(tp->dev); + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); return 0; @@ -4653,6 +4680,7 @@ static int tg3_ethtool_ioctl (struct net_device *dev, void *useraddr) return -EFAULT; spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); if (epause.autoneg) tp->tg3_flags |= TG3_FLAG_PAUSE_AUTONEG; else @@ -4668,6 +4696,7 @@ static int tg3_ethtool_ioctl (struct net_device *dev, void *useraddr) tg3_halt(tp); tg3_init_rings(tp); tg3_init_hw(tp); + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); return 0; @@ -4805,7 +4834,9 @@ static void tg3_vlan_rx_register(struct net_device *dev, struct vlan_group *grp) struct tg3 *tp = dev->priv; spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); tp->vlgrp = grp; + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); } @@ -4814,8 +4845,10 @@ static void tg3_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) struct tg3 *tp = dev->priv; spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); if (tp->vlgrp) tp->vlgrp->vlan_devices[vid] = NULL; + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); } #endif @@ -5926,6 +5959,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, tp->grc_mode |= GRC_MODE_BSWAP_NONFRM_DATA; #endif spin_lock_init(&tp->lock); + spin_lock_init(&tp->tx_lock); spin_lock_init(&tp->indirect_lock); tp->regs = (unsigned long) ioremap(tg3reg_base, tg3reg_len); @@ -6061,22 +6095,28 @@ static int tg3_suspend(struct pci_dev *pdev, u32 state) return 0; spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); tg3_disable_ints(tp); + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); netif_device_detach(dev); spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); tg3_halt(tp); + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); err = tg3_set_power_state(tp, state); if (err) { spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); tg3_init_rings(tp); tg3_init_hw(tp); + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); netif_device_attach(dev); @@ -6101,11 +6141,13 @@ static int tg3_resume(struct pci_dev *pdev) netif_device_attach(dev); spin_lock_irq(&tp->lock); + spin_lock(&tp->tx_lock); tg3_init_rings(tp); tg3_init_hw(tp); tg3_enable_ints(tp); + spin_unlock(&tp->tx_lock); spin_unlock_irq(&tp->lock); return 0; diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index 86500c6a976e..02b7b77d5f4c 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h @@ -1701,7 +1701,21 @@ struct tg3_bufmgr_config { }; struct tg3 { + /* SMP locking strategy: + * + * lock: Held during all operations except TX packet + * processing. + * + * tx_lock: Held during tg3_start_xmit{,_4gbug} and tg3_tx + * + * If you want to shut up all asynchronous processing you must + * acquire both locks, 'lock' taken before 'tx_lock'. IRQs must + * be disabled to take 'lock' but only softirq disabling is + * necessary for acquisition of 'tx_lock'. + */ spinlock_t lock; + spinlock_t tx_lock; + u32 tx_prod; u32 tx_cons; u32 rx_rcb_ptr; @@ -1716,11 +1730,6 @@ struct tg3 { struct net_device_stats net_stats_prev; unsigned long phy_crc_errors; - /* Adaptive coalescing engine. */ - unsigned long last_rate_sample; - u32 last_rx_count; - u32 last_tx_count; - u32 rx_offset; u32 tg3_flags; #define TG3_FLAG_HOST_TXDS 0x00000001 @@ -1728,8 +1737,6 @@ struct tg3 { #define TG3_FLAG_RX_CHECKSUMS 0x00000004 #define TG3_FLAG_USE_LINKCHG_REG 0x00000008 #define TG3_FLAG_USE_MI_INTERRUPT 0x00000010 -#define TG3_FLAG_ADAPTIVE_RX 0x00000020 -#define TG3_FLAG_ADAPTIVE_TX 0x00000040 #define TG3_FLAG_POLL_SERDES 0x00000080 #define TG3_FLAG_PHY_RESET_ON_INIT 0x00000100 #define TG3_FLAG_PCIX_TARGET_HWBUG 0x00000200 diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h index 06a263d94b4b..fec8ad62b567 100644 --- a/include/linux/pkt_sched.h +++ b/include/linux/pkt_sched.h @@ -248,6 +248,48 @@ struct tc_gred_sopt __u8 grio; }; +/* HTB section */ +#define TC_HTB_NUMPRIO 8 +#define TC_HTB_MAXDEPTH 8 +#define TC_HTB_PROTOVER 3 /* the same as HTB and TC's major */ + +struct tc_htb_opt +{ + struct tc_ratespec rate; + struct tc_ratespec ceil; + __u32 buffer; + __u32 cbuffer; + __u32 quantum; + __u32 level; /* out only */ + __u32 prio; +}; +struct tc_htb_glob +{ + __u32 version; /* to match HTB/TC */ + __u32 rate2quantum; /* bps->quantum divisor */ + __u32 defcls; /* default class number */ + __u32 debug; /* debug flags */ + + /* stats */ + __u32 direct_pkts; /* count of non shapped packets */ +}; +enum +{ + TCA_HTB_UNSPEC, + TCA_HTB_PARMS, + TCA_HTB_INIT, + TCA_HTB_CTAB, + TCA_HTB_RTAB, +}; +struct tc_htb_xstats +{ + __u32 lends; + __u32 borrows; + __u32 giants; /* too big packets (rate will not be accurate) */ + __u32 tokens; + __u32 ctokens; +}; + /* CBQ section */ #define TC_CBQ_MAXPRIO 8 diff --git a/include/net/tcp.h b/include/net/tcp.h index ae3b35eb282e..07102180d2fa 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -153,6 +153,9 @@ static __inline__ int tcp_bhashfn(__u16 lport) return (lport & (tcp_bhash_size - 1)); } +extern void tcp_bind_hash(struct sock *sk, struct tcp_bind_bucket *tb, + unsigned short snum); + /* This is a TIME_WAIT bucket. It works around the memory consumption * problems of sockets in such a state on heavily loaded servers, but * without violating the protocol specification. diff --git a/net/802/p8022.c b/net/802/p8022.c index 559d8fa66308..353321cc8c0b 100644 --- a/net/802/p8022.c +++ b/net/802/p8022.c @@ -25,9 +25,9 @@ #include <net/p8022.h> extern void llc_register_sap(unsigned char sap, - int (*rcvfunc)(struct sk_buff *, - struct net_device *, - struct packet_type *)); + int (*rcvfunc)(struct sk_buff *, + struct net_device *, + struct packet_type *)); extern void llc_unregister_sap(unsigned char sap); static struct datalink_proto *p8022_list; @@ -124,3 +124,5 @@ void unregister_8022_client(unsigned char type) EXPORT_SYMBOL(register_8022_client); EXPORT_SYMBOL(unregister_8022_client); + +MODULE_LICENSE("GPL"); diff --git a/net/802/psnap.c b/net/802/psnap.c index 907ac1b54652..3c953b8c1273 100644 --- a/net/802/psnap.c +++ b/net/802/psnap.c @@ -1,7 +1,8 @@ /* * SNAP data link layer. Derived from 802.2 * - * Alan Cox <Alan.Cox@linux.org>, from the 802.2 layer by Greg Page. + * Alan Cox <Alan.Cox@linux.org>, + * from the 802.2 layer by Greg Page. * Merged in additions from Greg Page's psnap.c. * * This program is free software; you can redistribute it and/or @@ -20,50 +21,39 @@ #include <linux/in.h> #include <linux/init.h> -static struct datalink_proto *snap_list = NULL; -static struct datalink_proto *snap_dl = NULL; /* 802.2 DL for SNAP */ +static struct datalink_proto *snap_list; +static struct datalink_proto *snap_dl; /* 802.2 DL for SNAP */ /* * Find a snap client by matching the 5 bytes. */ - static struct datalink_proto *find_snap_client(unsigned char *desc) { - struct datalink_proto *proto; + struct datalink_proto *proto = snap_list; + + for (; proto && memcmp(proto->type, desc, 5); proto = proto->next); - for (proto = snap_list; proto != NULL && memcmp(proto->type, desc, 5) ; proto = proto->next); return proto; } /* * A SNAP packet has arrived */ - -int snap_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) +int snap_rcv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt) { - static struct packet_type psnap_packet_type = - { - 0, - NULL, /* All Devices */ - snap_rcv, - NULL, - NULL, + static struct packet_type psnap_packet_type = { + .type = __constant_htons(ETH_P_SNAP), + .func = snap_rcv, }; - struct datalink_proto *proto; - - proto = find_snap_client(skb->h.raw); - if (proto != NULL) - { - /* - * Pass the frame on. - */ + struct datalink_proto *proto = find_snap_client(skb->h.raw); - skb->h.raw += 5; + if (proto) { + /* Pass the frame on. */ + skb->h.raw += 5; skb->nh.raw += 5; - skb_pull(skb,5); - if (psnap_packet_type.type == 0) - psnap_packet_type.type=htons(ETH_P_SNAP); + skb_pull(skb, 5); return proto->rcvfunc(skb, dev, &psnap_packet_type); } @@ -75,60 +65,62 @@ int snap_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt /* * Put a SNAP header on a frame and pass to 802.2 */ - -static void snap_datalink_header(struct datalink_proto *dl, struct sk_buff *skb, unsigned char *dest_node) +static void snap_datalink_header(struct datalink_proto *dl, + struct sk_buff *skb, unsigned char *dest_node) { - memcpy(skb_push(skb,5),dl->type,5); + memcpy(skb_push(skb, 5), dl->type, 5); snap_dl->datalink_header(snap_dl, skb, dest_node); } /* * Set up the SNAP layer */ - EXPORT_SYMBOL(register_snap_client); EXPORT_SYMBOL(unregister_snap_client); static int __init snap_init(void) { - snap_dl=register_8022_client(0xAA, snap_rcv); - if(snap_dl==NULL) - printk("SNAP - unable to register with 802.2\n"); + snap_dl = register_8022_client(0xAA, snap_rcv); + + if (!snap_dl) + printk(KERN_CRIT "SNAP - unable to register with 802.2\n"); + return 0; } + module_init(snap_init); /* * Register SNAP clients. We don't yet use this for IP. */ - -struct datalink_proto *register_snap_client(unsigned char *desc, int (*rcvfunc)(struct sk_buff *, struct net_device *, struct packet_type *)) +struct datalink_proto *register_snap_client(unsigned char *desc, + int (*rcvfunc)(struct sk_buff *, + struct net_device *, + struct packet_type *)) { - struct datalink_proto *proto; + struct datalink_proto *proto = NULL; - if (find_snap_client(desc) != NULL) - return NULL; + if (find_snap_client(desc)) + goto out; - proto = (struct datalink_proto *) kmalloc(sizeof(*proto), GFP_ATOMIC); - if (proto != NULL) - { + proto = kmalloc(sizeof(*proto), GFP_ATOMIC); + if (proto) { memcpy(proto->type, desc,5); - proto->type_len = 5; - proto->rcvfunc = rcvfunc; - proto->header_length = 5+snap_dl->header_length; - proto->datalink_header = snap_datalink_header; - proto->string_name = "SNAP"; - proto->next = snap_list; - snap_list = proto; + proto->type_len = 5; + proto->rcvfunc = rcvfunc; + proto->header_length = 5 + snap_dl->header_length; + proto->datalink_header = snap_datalink_header; + proto->string_name = "SNAP"; + proto->next = snap_list; + snap_list = proto; } - +out: return proto; } /* * Unregister SNAP clients. Protocols no longer want to play with us ... */ - void unregister_snap_client(unsigned char *desc) { struct datalink_proto **clients = &snap_list; @@ -138,17 +130,16 @@ void unregister_snap_client(unsigned char *desc) save_flags(flags); cli(); - while ((tmp = *clients) != NULL) - { - if (memcmp(tmp->type,desc,5) == 0) - { + while ((tmp = *clients) != NULL) { + if (!memcmp(tmp->type, desc, 5)) { *clients = tmp->next; kfree(tmp); break; - } - else + } else clients = &tmp->next; } restore_flags(flags); } + +MODULE_LICENSE("GPL"); diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index 0e10441071ed..5865f134cbd5 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c @@ -52,7 +52,7 @@ static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>"; static int vlan_device_event(struct notifier_block *, unsigned long, void *); struct notifier_block vlan_notifier_block = { - notifier_call: vlan_device_event, + .notifier_call = vlan_device_event, }; /* These may be changed at run-time through IOCTLs */ @@ -64,11 +64,11 @@ unsigned short vlan_name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD; unsigned short vlan_default_dev_flags = 1; static struct packet_type vlan_packet_type = { - type: __constant_htons(ETH_P_8021Q), - dev: NULL, - func: vlan_skb_recv, /* VLAN receive method */ - data: (void *)(-1), /* Set here '(void *)1' when this code can SHARE SKBs */ - next: NULL + .type = __constant_htons(ETH_P_8021Q), + .dev =NULL, + .func = vlan_skb_recv, /* VLAN receive method */ + .data = (void *)(-1), /* Set here '(void *)1' when this code can SHARE SKBs */ + .next = NULL }; /* End of global variables definitions. */ diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c index 58504f5c30a6..b5b294b34aa8 100644 --- a/net/8021q/vlanproc.c +++ b/net/8021q/vlanproc.c @@ -75,8 +75,8 @@ static char term_msg[] = "***KERNEL: Out of buffer space!***\n"; */ static struct file_operations vlan_fops = { - read: vlan_proc_read, - ioctl: NULL, /* vlan_proc_ioctl */ + .read = vlan_proc_read, + .ioctl = NULL, /* vlan_proc_ioctl */ }; /* @@ -84,8 +84,8 @@ static struct file_operations vlan_fops = { */ static struct file_operations vlandev_fops = { - read: vlan_proc_read, - ioctl: NULL, /* vlan_proc_ioctl */ + .read = vlan_proc_read, + .ioctl =NULL, /* vlan_proc_ioctl */ }; /* diff --git a/net/appletalk/aarp.c b/net/appletalk/aarp.c index f5048d1f7e13..55ca43d7ca6b 100644 --- a/net/appletalk/aarp.c +++ b/net/appletalk/aarp.c @@ -66,17 +66,29 @@ int sysctl_aarp_retransmit_limit = AARP_RETRANSMIT_LIMIT; int sysctl_aarp_resolve_time = AARP_RESOLVE_TIME; /* Lists of aarp entries */ +/** + * struct aarp_entry - AARP entry + * @last_sent - Last time we xmitted the aarp request + * @packet_queue - Queue of frames wait for resolution + * @status - Used for proxy AARP + * expires_at - Entry expiry time + * target_addr - DDP Address + * dev - Device to use + * hwaddr - Physical i/f address of target/router + * xmit_count - When this hits 10 we give up + * next - Next entry in chain + */ struct aarp_entry { /* These first two are only used for unresolved entries */ - unsigned long last_sent; /* Last time we xmitted the aarp request */ - struct sk_buff_head packet_queue; /* Queue of frames wait for resolution */ - int status; /* Used for proxy AARP */ - unsigned long expires_at; /* Entry expiry time */ - struct at_addr target_addr; /* DDP Address */ - struct net_device *dev; /* Device to use */ - char hwaddr[6]; /* Physical i/f address of target/router */ - unsigned short xmit_count; /* When this hits 10 we give up */ - struct aarp_entry *next; /* Next entry in chain */ + unsigned long last_sent; + struct sk_buff_head packet_queue; + int status; + unsigned long expires_at; + struct at_addr target_addr; + struct net_device *dev; + char hwaddr[6]; + unsigned short xmit_count; + struct aarp_entry *next; }; /* Hashed list of resolved, unresolved and proxy entries */ @@ -371,7 +383,7 @@ static int aarp_device_event(struct notifier_block *this, unsigned long event, static struct aarp_entry *aarp_alloc(void) { - struct aarp_entry *a = kmalloc(sizeof(struct aarp_entry), GFP_ATOMIC); + struct aarp_entry *a = kmalloc(sizeof(*a), GFP_ATOMIC); if (a) skb_queue_head_init(&a->packet_queue); @@ -430,22 +442,22 @@ static struct at_addr *__aarp_proxy_find(struct net_device *dev, */ void aarp_send_probe_phase1(struct atalk_iface *iface) { - struct ifreq atreq; - struct sockaddr_at *sa = (struct sockaddr_at *)&atreq.ifr_addr; - - sa->sat_addr.s_node = iface->address.s_node; - sa->sat_addr.s_net = ntohs(iface->address.s_net); - - /* We pass the Net:Node to the drivers/cards by a Device ioctl. */ - if (!(iface->dev->do_ioctl(iface->dev, &atreq, SIOCSIFADDR))) { - (void)iface->dev->do_ioctl(iface->dev, &atreq, SIOCGIFADDR); - if (iface->address.s_net != htons(sa->sat_addr.s_net) || - iface->address.s_node != sa->sat_addr.s_node) - iface->status |= ATIF_PROBE_FAIL; - - iface->address.s_net = htons(sa->sat_addr.s_net); - iface->address.s_node = sa->sat_addr.s_node; - } + struct ifreq atreq; + struct sockaddr_at *sa = (struct sockaddr_at *)&atreq.ifr_addr; + + sa->sat_addr.s_node = iface->address.s_node; + sa->sat_addr.s_net = ntohs(iface->address.s_net); + + /* We pass the Net:Node to the drivers/cards by a Device ioctl. */ + if (!(iface->dev->do_ioctl(iface->dev, &atreq, SIOCSIFADDR))) { + (void)iface->dev->do_ioctl(iface->dev, &atreq, SIOCGIFADDR); + if (iface->address.s_net != htons(sa->sat_addr.s_net) || + iface->address.s_node != sa->sat_addr.s_node) + iface->status |= ATIF_PROBE_FAIL; + + iface->address.s_net = htons(sa->sat_addr.s_net); + iface->address.s_node = sa->sat_addr.s_node; + } } @@ -462,7 +474,7 @@ void aarp_probe_network(struct atalk_iface *atif) /* Defer 1/10th */ current->state = TASK_INTERRUPTIBLE; - schedule_timeout(HZ/10); + schedule_timeout(HZ / 10); if (atif->status & ATIF_PROBE_FAIL) break; @@ -472,7 +484,7 @@ void aarp_probe_network(struct atalk_iface *atif) int aarp_proxy_probe_network(struct atalk_iface *atif, struct at_addr *sa) { - int hash, retval = 1; + int hash, retval = -EPROTONOSUPPORT; struct aarp_entry *entry; unsigned int count; @@ -480,19 +492,18 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct at_addr *sa) * we don't currently support LocalTalk or PPP for proxy AARP; * if someone wants to try and add it, have fun */ - if (atif->dev->type == ARPHRD_LOCALTLK) - return -EPROTONOSUPPORT; - - if (atif->dev->type == ARPHRD_PPP) - return -EPROTONOSUPPORT; + if (atif->dev->type == ARPHRD_LOCALTLK || + atif->dev->type == ARPHRD_PPP) + goto out; /* * create a new AARP entry with the flags set to be published -- * we need this one to hang around even if it's in use */ entry = aarp_alloc(); + retval = -ENOMEM; if (!entry) - return -ENOMEM; + goto out; entry->expires_at = -1; entry->status = ATIF_PROBE; @@ -512,7 +523,7 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct at_addr *sa) /* Defer 1/10th */ current->state = TASK_INTERRUPTIBLE; spin_unlock_bh(&aarp_lock); - schedule_timeout(HZ/10); + schedule_timeout(HZ / 10); spin_lock_bh(&aarp_lock); if (entry->status & ATIF_PROBE_FAIL) @@ -522,10 +533,13 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct at_addr *sa) if (entry->status & ATIF_PROBE_FAIL) { entry->expires_at = jiffies - 1; /* free the entry */ retval = -EADDRINUSE; /* return network full */ - } else /* clear the probing flag */ + } else { /* clear the probing flag */ entry->status &= ~ATIF_PROBE; + retval = 1; + } spin_unlock_bh(&aarp_lock); +out: return retval; } @@ -613,8 +627,7 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb, a = __aarp_find_entry(unresolved[hash], dev, sa); if (a) { /* Queue onto the unresolved queue */ skb_queue_tail(&a->packet_queue, skb); - spin_unlock_bh(&aarp_lock); - return 0; + goto out_unlock; } /* Allocate a new entry */ @@ -627,11 +640,11 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb, /* Set up the queue */ skb_queue_tail(&a->packet_queue, skb); - a->expires_at = jiffies + sysctl_aarp_resolve_time; - a->dev = dev; - a->next = unresolved[hash]; - a->target_addr = *sa; - a->xmit_count = 0; + a->expires_at = jiffies + sysctl_aarp_resolve_time; + a->dev = dev; + a->next = unresolved[hash]; + a->target_addr = *sa; + a->xmit_count = 0; unresolved[hash] = a; unresolved_count++; @@ -647,12 +660,14 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb, mod_timer(&aarp_timer, jiffies + sysctl_aarp_tick_time); /* Now finally, it is safe to drop the lock. */ +out_unlock: spin_unlock_bh(&aarp_lock); /* Tell the ddp layer we have taken over for this frame. */ return 0; -sendit: if (skb->sk) +sendit: + if (skb->sk) skb->priority = skb->sk->priority; dev_queue_xmit(skb); return 1; @@ -696,7 +711,7 @@ static void __aarp_resolved(struct aarp_entry **list, struct aarp_entry *a, * frame. We currently only support Ethernet. */ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt) + struct packet_type *pt) { struct elapaarp *ea = (struct elapaarp *)skb->h.raw; int hash, ret = 0; @@ -742,7 +757,7 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev, /* Check for replies of proxy AARP entries */ da.s_node = ea->pa_dst_node; - da.s_net = ea->pa_dst_net; + da.s_net = ea->pa_dst_net; spin_lock_bh(&aarp_lock); a = __aarp_find_entry(proxies[hash], dev, &da); @@ -834,14 +849,17 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev, break; } -unlock: spin_unlock_bh(&aarp_lock); -out1: ret = 1; -out0: kfree_skb(skb); +unlock: + spin_unlock_bh(&aarp_lock); +out1: + ret = 1; +out0: + kfree_skb(skb); return ret; } static struct notifier_block aarp_notifier = { - notifier_call: aarp_device_event, + .notifier_call =aarp_device_event, }; static char aarp_snap_id[] = { 0x00, 0x00, 0x00, 0x80, 0xF3 }; @@ -853,8 +871,8 @@ void __init aarp_proto_init(void) printk(KERN_CRIT "Unable to register AARP with SNAP.\n"); init_timer(&aarp_timer); aarp_timer.function = aarp_expire_timeout; - aarp_timer.data = 0; - aarp_timer.expires = jiffies + sysctl_aarp_expiry_time; + aarp_timer.data = 0; + aarp_timer.expires = jiffies + sysctl_aarp_expiry_time; add_timer(&aarp_timer); register_netdevice_notifier(&aarp_notifier); } @@ -880,81 +898,84 @@ static int aarp_get_info(char *buffer, char **start, off_t offset, int length) { /* we should dump all our AARP entries */ struct aarp_entry *entry; - int len, ct; - - len = sprintf(buffer, - "%-10.10s %-10.10s%-18.18s%12.12s%12.12s xmit_count status\n", - "address", "device", "hw addr", "last_sent", "expires"); + int ct, len = sprintf(buffer, + "%-10.10s %-10.10s%-18.18s%12.12s%12.12s " + "xmit_count status\n", + "address", "device", "hw addr", "last_sent", + "expires"); spin_lock_bh(&aarp_lock); for (ct = 0; ct < AARP_HASH_SIZE; ct++) { for (entry = resolved[ct]; entry; entry = entry->next) { - len+= sprintf(buffer+len,"%6u:%-3u ", + len += sprintf(buffer + len, "%6u:%-3u ", (unsigned int)ntohs(entry->target_addr.s_net), (unsigned int)(entry->target_addr.s_node)); - len+= sprintf(buffer+len,"%-10.10s", - entry->dev->name); - len+= sprintf(buffer+len,"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", - (int)(entry->hwaddr[0] & 0x000000FF), - (int)(entry->hwaddr[1] & 0x000000FF), - (int)(entry->hwaddr[2] & 0x000000FF), - (int)(entry->hwaddr[3] & 0x000000FF), - (int)(entry->hwaddr[4] & 0x000000FF), - (int)(entry->hwaddr[5] & 0x000000FF)); - len+= sprintf(buffer+len,"%12lu ""%12lu ", - (unsigned long)entry->last_sent, - (unsigned long)entry->expires_at); - len+=sprintf(buffer+len,"%10u", - (unsigned int)entry->xmit_count); - - len+=sprintf(buffer+len," resolved\n"); + len += sprintf(buffer + len, "%-10.10s", + entry->dev->name); + len += sprintf(buffer + len, + "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", + (int)(entry->hwaddr[0] & 0x000000FF), + (int)(entry->hwaddr[1] & 0x000000FF), + (int)(entry->hwaddr[2] & 0x000000FF), + (int)(entry->hwaddr[3] & 0x000000FF), + (int)(entry->hwaddr[4] & 0x000000FF), + (int)(entry->hwaddr[5] & 0x000000FF)); + len += sprintf(buffer + len, "%12lu ""%12lu ", + (unsigned long)entry->last_sent, + (unsigned long)entry->expires_at); + len += sprintf(buffer + len, "%10u", + (unsigned int)entry->xmit_count); + + len += sprintf(buffer + len, " resolved\n"); } } for (ct = 0; ct < AARP_HASH_SIZE; ct++) { for (entry = unresolved[ct]; entry; entry = entry->next) { - len+= sprintf(buffer+len,"%6u:%-3u ", + len += sprintf(buffer + len, "%6u:%-3u ", (unsigned int)ntohs(entry->target_addr.s_net), (unsigned int)(entry->target_addr.s_node)); - len+= sprintf(buffer+len,"%-10.10s", - entry->dev->name); - len+= sprintf(buffer+len,"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", - (int)(entry->hwaddr[0] & 0x000000FF), - (int)(entry->hwaddr[1] & 0x000000FF), - (int)(entry->hwaddr[2] & 0x000000FF), - (int)(entry->hwaddr[3] & 0x000000FF), - (int)(entry->hwaddr[4] & 0x000000FF), - (int)(entry->hwaddr[5] & 0x000000FF)); - len+= sprintf(buffer+len,"%12lu ""%12lu ", - (unsigned long)entry->last_sent, - (unsigned long)entry->expires_at); - len+=sprintf(buffer+len,"%10u", - (unsigned int)entry->xmit_count); - len+=sprintf(buffer+len," unresolved\n"); + len += sprintf(buffer + len, "%-10.10s", + entry->dev->name); + len += sprintf(buffer + len, + "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", + (int)(entry->hwaddr[0] & 0x000000FF), + (int)(entry->hwaddr[1] & 0x000000FF), + (int)(entry->hwaddr[2] & 0x000000FF), + (int)(entry->hwaddr[3] & 0x000000FF), + (int)(entry->hwaddr[4] & 0x000000FF), + (int)(entry->hwaddr[5] & 0x000000FF)); + len += sprintf(buffer + len, "%12lu ""%12lu ", + (unsigned long)entry->last_sent, + (unsigned long)entry->expires_at); + len += sprintf(buffer + len, "%10u", + (unsigned int)entry->xmit_count); + len += sprintf(buffer + len, " unresolved\n"); } } for (ct = 0; ct < AARP_HASH_SIZE; ct++) { for (entry = proxies[ct]; entry; entry = entry->next) { - len+= sprintf(buffer+len,"%6u:%-3u ", + len += sprintf(buffer + len, "%6u:%-3u ", (unsigned int)ntohs(entry->target_addr.s_net), (unsigned int)(entry->target_addr.s_node)); - len+= sprintf(buffer+len,"%-10.10s", - entry->dev->name); - len+= sprintf(buffer+len,"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", - (int)(entry->hwaddr[0] & 0x000000FF), - (int)(entry->hwaddr[1] & 0x000000FF), - (int)(entry->hwaddr[2] & 0x000000FF), - (int)(entry->hwaddr[3] & 0x000000FF), - (int)(entry->hwaddr[4] & 0x000000FF), - (int)(entry->hwaddr[5] & 0x000000FF)); - len+= sprintf(buffer+len,"%12lu ""%12lu ", - (unsigned long)entry->last_sent, - (unsigned long)entry->expires_at); - len+=sprintf(buffer+len,"%10u", - (unsigned int)entry->xmit_count); - len+=sprintf(buffer+len," proxy\n"); + len += sprintf(buffer + len, "%-10.10s", + entry->dev->name); + len += sprintf(buffer + len, + "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", + (int)(entry->hwaddr[0] & 0x000000FF), + (int)(entry->hwaddr[1] & 0x000000FF), + (int)(entry->hwaddr[2] & 0x000000FF), + (int)(entry->hwaddr[3] & 0x000000FF), + (int)(entry->hwaddr[4] & 0x000000FF), + (int)(entry->hwaddr[5] & 0x000000FF)); + len += sprintf(buffer + len, "%12lu ""%12lu ", + (unsigned long)entry->last_sent, + (unsigned long)entry->expires_at); + len += sprintf(buffer + len, "%10u", + (unsigned int)entry->xmit_count); + len += sprintf(buffer + len, " proxy\n"); } } diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index a8b7826fc2f6..e5be5f439698 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c @@ -99,13 +99,6 @@ extern int aarp_proxy_probe_network(struct atalk_iface *atif, struct at_addr *sa); extern void aarp_proxy_remove(struct net_device *dev, struct at_addr *sa); -#undef APPLETALK_DEBUG -#ifdef APPLETALK_DEBUG -#define DPRINT(x) print(x) -#else -#define DPRINT(x) -#endif /* APPLETALK_DEBUG */ - #ifdef CONFIG_SYSCTL extern inline void atalk_register_sysctl(void); extern inline void atalk_unregister_sysctl(void); @@ -182,10 +175,13 @@ static struct sock *atalk_search_socket(struct sockaddr_at *to, return s; } -/* - * Try to find a socket matching ADDR in the socket list, - * if found then return it. If not, insert SK into the - * socket list. +/** + * atalk_find_or_insert_socket - Try to find a socket matching ADDR + * @sk - socket to insert in the list if it is not there already + * @sat - address to search for + * + * Try to find a socket matching ADDR in the socket list, if found then return + * it. If not, insert SK into the socket list. * * This entire operation must execute atomically. */ @@ -219,7 +215,7 @@ static struct sock *atalk_find_or_insert_socket(struct sock *sk, static void atalk_destroy_timer(unsigned long data) { - struct sock *sk = (struct sock *) data; + struct sock *sk = (struct sock *)data; if (!atomic_read(&sk->wmem_alloc) && !atomic_read(&sk->rmem_alloc) && sk->dead) { @@ -263,16 +259,16 @@ static int atalk_get_info(char *buffer, char **start, off_t offset, int length) for (s = atalk_sockets; s; s = s->next) { struct atalk_sock *at = at_sk(s); - len += sprintf(buffer + len,"%02X ", s->type); - len += sprintf(buffer + len,"%04X:%02X:%02X ", + len += sprintf(buffer + len, "%02X ", s->type); + len += sprintf(buffer + len, "%04X:%02X:%02X ", ntohs(at->src_net), at->src_node, at->src_port); - len += sprintf(buffer + len,"%04X:%02X:%02X ", + len += sprintf(buffer + len, "%04X:%02X:%02X ", ntohs(at->dest_net), at->dest_node, at->dest_port); - len += sprintf(buffer + len,"%08X:%08X ", + len += sprintf(buffer + len, "%08X:%08X ", atomic_read(&s->wmem_alloc), atomic_read(&s->rmem_alloc)); - len += sprintf(buffer + len,"%02X %d\n", s->state, + len += sprintf(buffer + len, "%02X %d\n", s->state, SOCK_INODE(s->socket)->i_uid); /* Are we still dumping unwanted data then discard the record */ @@ -287,7 +283,7 @@ static int atalk_get_info(char *buffer, char **start, off_t offset, int length) } spin_unlock_bh(&atalk_sockets_lock); - /* The data in question runs from begin to begin+len */ + /* The data in question runs from begin to begin + len */ *start = buffer + offset - begin; /* Start of wanted data */ len -= offset - begin; /* Remove unwanted header data from length */ if (len > length) @@ -338,10 +334,13 @@ static void atif_drop_device(struct net_device *dev) static struct atalk_iface *atif_add_device(struct net_device *dev, struct at_addr *sa) { - struct atalk_iface *iface = kmalloc(sizeof(*iface), GFP_KERNEL); + struct atalk_iface *iface; + + MOD_INC_USE_COUNT; + iface = kmalloc(sizeof(*iface), GFP_KERNEL); if (!iface) - return NULL; + goto out_mem; iface->dev = dev; dev->atalk_ptr = iface; @@ -352,9 +351,11 @@ static struct atalk_iface *atif_add_device(struct net_device *dev, iface->next = atalk_iface_list; atalk_iface_list = iface; spin_unlock_bh(&atalk_iface_lock); - - MOD_INC_USE_COUNT; +out: return iface; +out_mem: + MOD_DEC_USE_COUNT; + goto out; } /* Perform phase 2 AARP probing on our tentative address */ @@ -381,7 +382,7 @@ static int atif_probe_device(struct atalk_iface *atif) /* Sweep the available nodes from a given start */ atif->address.s_net = htons(probe_net); for (nodect = 0; nodect < 256; nodect++) { - atif->address.s_node = ((nodect+probe_node) & 0xFF); + atif->address.s_node = (nodect + probe_node) & 0xFF; if (atif->address.s_node > 0 && atif->address.s_node < 254) { /* Probe a proposed address */ @@ -430,7 +431,7 @@ static int atif_proxy_probe_device(struct atalk_iface *atif, /* Sweep the available nodes from a given start */ proxy_addr->s_net = htons(probe_net); for (nodect = 0; nodect < 256; nodect++) { - proxy_addr->s_node = ((nodect + probe_node) & 0xFF); + proxy_addr->s_node = (nodect + probe_node) & 0xFF; if (proxy_addr->s_node > 0 && proxy_addr->s_node < 254) { /* Tell AARP to probe a proposed address */ @@ -482,7 +483,8 @@ static struct at_addr *atalk_find_primary(void) retval = &atalk_iface_list->address; else retval = NULL; -out: spin_unlock_bh(&atalk_iface_lock); +out: + spin_unlock_bh(&atalk_iface_lock); return retval; } @@ -577,7 +579,8 @@ static struct atalk_route *atrtr_find(struct at_addr *target) r = &atrtr_default; else /* No route can be found */ r = NULL; -out: read_unlock_bh(&atalk_router_lock); +out: + read_unlock_bh(&atalk_router_lock); return r; } @@ -612,7 +615,7 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint) struct sockaddr_at *ga = (struct sockaddr_at *)&r->rt_gateway; struct atalk_route *rt; struct atalk_iface *iface, *riface; - int retval; + int retval = -EINVAL; /* * Fixme: Raise/Lower a routing change semaphore for these @@ -620,11 +623,9 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint) */ /* Validate the request */ - if (ta->sat_family != AF_APPLETALK) - return -EINVAL; - - if (!devhint && ga->sat_family != AF_APPLETALK) - return -EINVAL; + if (ta->sat_family != AF_APPLETALK || + (!devhint && ga->sat_family != AF_APPLETALK)) + goto out; /* Now walk the routing table and make our decisions */ write_lock_bh(&atalk_router_lock); @@ -660,13 +661,13 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint) retval = -ENETUNREACH; if (!riface) - goto out; + goto out_unlock; devhint = riface->dev; } if (!rt) { - rt = kmalloc(sizeof(struct atalk_route), GFP_ATOMIC); + rt = kmalloc(sizeof(*rt), GFP_ATOMIC); retval = -ENOBUFS; if (!rt) @@ -683,7 +684,9 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint) rt->gateway = ga->sat_addr; retval = 0; -out: write_unlock_bh(&atalk_router_lock); +out_unlock: + write_unlock_bh(&atalk_router_lock); +out: return retval; } @@ -706,7 +709,8 @@ static int atrtr_delete(struct at_addr * addr) r = &tmp->next; } retval = -ENOENT; -out: write_unlock_bh(&atalk_router_lock); +out: + write_unlock_bh(&atalk_router_lock); return retval; } @@ -750,7 +754,7 @@ static int ddp_device_event(struct notifier_block *this, unsigned long event, { if (event == NETDEV_DOWN) /* Discard any use of this */ - atalk_dev_down((struct net_device *) ptr); + atalk_dev_down(ptr); return NOTIFY_DONE; } @@ -759,7 +763,7 @@ static int ddp_device_event(struct notifier_block *this, unsigned long event, /* Device configuration ioctl calls */ static int atif_ioctl(int cmd, void *arg) { - static char aarp_mcast[6] = {0x09, 0x00, 0x00, 0xFF, 0xFF, 0xFF}; + static char aarp_mcast[6] = { 0x09, 0x00, 0x00, 0xFF, 0xFF, 0xFF }; struct ifreq atreq; struct netrange *nr; struct sockaddr_at *sa; @@ -777,7 +781,7 @@ static int atif_ioctl(int cmd, void *arg) if (!dev) return -ENODEV; - sa = (struct sockaddr_at*) &atreq.ifr_addr; + sa = (struct sockaddr_at *)&atreq.ifr_addr; atif = atalk_find_dev(dev); switch (cmd) { @@ -792,7 +796,7 @@ static int atif_ioctl(int cmd, void *arg) dev->type != ARPHRD_PPP) return -EPROTONOSUPPORT; - nr = (struct netrange *) &sa->sat_zero[0]; + nr = (struct netrange *)&sa->sat_zero[0]; add_route = 1; /* @@ -846,11 +850,11 @@ static int atif_ioctl(int cmd, void *arg) } /* Hey it worked - add the direct routes */ - sa = (struct sockaddr_at *) &rtdef.rt_gateway; + sa = (struct sockaddr_at *)&rtdef.rt_gateway; sa->sat_family = AF_APPLETALK; sa->sat_addr.s_net = atif->address.s_net; sa->sat_addr.s_node = atif->address.s_node; - sa = (struct sockaddr_at *) &rtdef.rt_dst; + sa = (struct sockaddr_at *)&rtdef.rt_dst; rtdef.rt_flags = RTF_UP; sa->sat_family = AF_APPLETALK; sa->sat_addr.s_node = ATADDR_ANYNODE; @@ -932,7 +936,7 @@ static int atif_ioctl(int cmd, void *arg) if (!atif) return -EADDRNOTAVAIL; - nr = (struct netrange *) &(atif->nets); + nr = (struct netrange *)&(atif->nets); /* * Phase 1 is fine on Localtalk but we don't do * Ethertalk phase 1. Anyone wanting to add it go ahead. @@ -1016,7 +1020,7 @@ static int atalk_if_get_info(char *buffer, char **start, off_t offset, spin_lock_bh(&atalk_iface_lock); for (iface = atalk_iface_list; iface; iface = iface->next) { - len += sprintf(buffer+len,"%-16s %04X:%02X %04X-%04X %d\n", + len += sprintf(buffer + len, "%-16s %04X:%02X %04X-%04X %d\n", iface->dev->name, ntohs(iface->address.s_net), iface->address.s_node, ntohs(iface->nets.nr_firstnet), @@ -1049,7 +1053,8 @@ static int atalk_rt_get_info(char *buffer, char **start, off_t offset, if (atrtr_default.dev) { rt = &atrtr_default; - len += sprintf(buffer + len,"Default %04X:%02X %-4d %s\n", + len += sprintf(buffer + len, + "Default %04X:%02X %-4d %s\n", ntohs(rt->gateway.s_net), rt->gateway.s_node, rt->flags, rt->dev->name); } @@ -1092,7 +1097,7 @@ static int atalk_rt_get_info(char *buffer, char **start, off_t offset, unsigned short atalk_checksum(struct ddpehdr *ddp, int len) { unsigned long sum = 0; /* Assume unsigned long is >16 bits */ - unsigned char *data = (unsigned char *) ddp; + unsigned char *data = (unsigned char *)ddp; len -= 4; /* skip header 4 bytes */ data += 4; @@ -1108,7 +1113,7 @@ unsigned short atalk_checksum(struct ddpehdr *ddp, int len) data++; } /* Use 0xFFFF for 0. 0 itself means none */ - return sum ? htons((unsigned short) sum) : 0xFFFF; + return sum ? htons((unsigned short)sum) : 0xFFFF; } /* @@ -1140,9 +1145,12 @@ static int atalk_create(struct socket *sock, int protocol) sock_init_data(sock, sk); /* Checksums on by default */ sk->zapped = 1; -out: return rc; -outsk: sk_free(sk); -decmod: MOD_DEC_USE_COUNT; +out: + return rc; +outsk: + sk_free(sk); +decmod: + MOD_DEC_USE_COUNT; goto out; } @@ -1158,13 +1166,17 @@ static int atalk_release(struct socket *sock) sk->dead = 1; sock->sk = NULL; atalk_destroy_socket(sk); -out: return 0; +out: + return 0; } -/* - * Pick a source port when one is not given. If we can - * find a suitable free one, we insert the socket into - * the tables using it. +/** + * atalk_pick_and_bind_port - Pick a source port when one is not given + * @sk - socket to insert into the tables + * @sat - address to search for + * + * Pick a source port when one is not given. If we can find a suitable free + * one, we insert the socket into the tables using it. * * This whole operation must be atomic. */ @@ -1197,12 +1209,12 @@ static int atalk_pick_and_bind_port(struct sock *sk, struct sockaddr_at *sat) retval = 0; goto out; - try_next_port: - ; +try_next_port:; } retval = -EBUSY; -out: spin_unlock_bh(&atalk_sockets_lock); +out: + spin_unlock_bh(&atalk_sockets_lock); return retval; } @@ -1210,21 +1222,20 @@ static int atalk_autobind(struct sock *sk) { struct atalk_sock *at = at_sk(sk); struct sockaddr_at sat; - int n; struct at_addr *ap = atalk_find_primary(); + int n = -EADDRNOTAVAIL; if (!ap || ap->s_net == htons(ATADDR_ANYNET)) - return -EADDRNOTAVAIL; + goto out; at->src_net = sat.sat_addr.s_net = ap->s_net; at->src_node = sat.sat_addr.s_node = ap->s_node; n = atalk_pick_and_bind_port(sk, &sat); - if (n < 0) - return n; - - sk->zapped = 0; - return 0; + if (!n) + sk->zapped = 0; +out: + return n; } /* Set the address 'our end' of the connection */ @@ -1355,7 +1366,12 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr, return 0; } -/* +/** + * atalk_rcv - Receive a packet (in skb) from device dev + * @skb - packet received + * @dev - network device where the packet comes from + * @pt - packet type + * * Receive a packet (in skb) from device dev. This has come from the SNAP * decoder, and on entry skb->h.raw is the DDP header, skb->len is the DDP * header, skb->len is the DDP length. The physical headers have been @@ -1363,9 +1379,9 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr, * [ie ARPHRD_ETHERTALK] */ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt) + struct packet_type *pt) { - struct ddpehdr *ddp = (void *) skb->h.raw; + struct ddpehdr *ddp = (void *)skb->h.raw; struct sock *sock; struct atalk_iface *atif; struct sockaddr_at tosat; @@ -1442,6 +1458,7 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev, rt = atrtr_find(&ta); if (!rt || ddphv.deh_hops == DDP_MAXHOPS) goto freeit; + /* FIXME: use skb->cb to be able to use shared skbs */ ddphv.deh_hops++; /* @@ -1454,10 +1471,12 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev, } /* Fix up skb->len field */ - skb_trim(skb, min_t(unsigned int, origlen, rt->dev->hard_header_len + - ddp_dl->header_length + ddphv.deh_len)); + skb_trim(skb, min_t(unsigned int, origlen, + (rt->dev->hard_header_len + + ddp_dl->header_length + ddphv.deh_len))); /* Mend the byte order */ + /* FIXME: use skb->cb to be able to use shared skbs */ *((__u16 *)ddp) = ntohs(*((__u16 *)&ddphv)); /* @@ -1515,11 +1534,11 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev, #endif /* * Which socket - atalk_search_socket() looks for a *full match* - * of the <net,node,port> tuple. + * of the <net, node, port> tuple. */ tosat.sat_addr.s_net = ddp->deh_dnet; tosat.sat_addr.s_node = ddp->deh_dnode; - tosat.sat_port = ddp->deh_dport; + tosat.sat_port = ddp->deh_dport; sock = atalk_search_socket(&tosat, atif); if (!sock) /* But not one of our sockets */ @@ -1530,9 +1549,11 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev, if (sock_queue_rcv_skb(sock, skb) < 0) goto freeit; +out: + return 0; +freeit: + kfree_skb(skb); goto out; -freeit: kfree_skb(skb); -out: return 0; } /* @@ -1543,25 +1564,21 @@ out: return 0; static int ltalk_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) { - struct ddpehdr *ddp; - struct at_addr *ap; - /* Expand any short form frames */ if (skb->mac.raw[2] == 1) { + struct ddpehdr *ddp; /* Find our address */ + struct at_addr *ap = atalk_find_dev_addr(dev); - ap = atalk_find_dev_addr(dev); - if (!ap || skb->len < sizeof(struct ddpshdr)) { - kfree_skb(skb); - return 0; - } - + if (!ap || skb->len < sizeof(struct ddpshdr)) + goto freeit; /* * The push leaves us with a ddephdr not an shdr, and * handily the port bytes in the right place preset. */ skb_push(skb, sizeof(*ddp) - 4); + /* FIXME: use skb->cb to be able to use shared skbs */ ddp = (struct ddpehdr *)skb->data; /* Now fill in the long header */ @@ -1590,10 +1607,13 @@ static int ltalk_rcv(struct sk_buff *skb, struct net_device *dev, skb->h.raw = skb->data; return atalk_rcv(skb, dev, pt); +freeit: + kfree_skb(skb); + return 0; } static int atalk_sendmsg(struct socket *sock, struct msghdr *msg, int len, - struct scm_cookie *scm) + struct scm_cookie *scm) { struct sock *sk = sock->sk; struct atalk_sock *at = at_sk(sk); @@ -1762,17 +1782,16 @@ static int atalk_recvmsg(struct socket *sock, struct msghdr *msg, int size, { struct sock *sk = sock->sk; struct sockaddr_at *sat = (struct sockaddr_at *)msg->msg_name; - struct ddpehdr *ddp = NULL; + struct ddpehdr *ddp; int copied = 0; int err = 0; struct ddpebits ddphv; - struct sk_buff *skb; - - skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, - flags & MSG_DONTWAIT, &err); + struct sk_buff *skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, + flags & MSG_DONTWAIT, &err); if (!skb) return err; + /* FIXME: use skb->cb to be able to use shared skbs */ ddp = (struct ddpehdr *)(skb->h.raw); *((__u16 *)&ddphv) = ntohs(*((__u16 *)ddp)); @@ -1791,7 +1810,7 @@ static int atalk_recvmsg(struct socket *sock, struct msghdr *msg, int size, msg->msg_flags |= MSG_TRUNC; } err = skb_copy_datagram_iovec(skb, sizeof(*ddp), - msg->msg_iov, copied); + msg->msg_iov, copied); } if (!err) { @@ -1805,14 +1824,14 @@ static int atalk_recvmsg(struct socket *sock, struct msghdr *msg, int size, } skb_free_datagram(sk, skb); /* Free the datagram. */ - return err ? err : copied; + return err ? : copied; } /* * AppleTalk ioctl calls. */ -static int atalk_ioctl(struct socket *sock,unsigned int cmd, unsigned long arg) +static int atalk_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { long amount = 0; struct sock *sk = sock->sk; @@ -1824,14 +1843,15 @@ static int atalk_ioctl(struct socket *sock,unsigned int cmd, unsigned long arg) if (amount < 0) amount = 0; break; - case TIOCINQ: - { - /* These two are safe on a single CPU system as only - * user tasks fiddle here */ + case TIOCINQ: { + /* + * These two are safe on a single CPU system as only + * user tasks fiddle here + */ struct sk_buff *skb = skb_peek(&sk->receive_queue); if (skb) - amount = skb->len-sizeof(struct ddpehdr); + amount = skb->len - sizeof(struct ddpehdr); break; } case SIOCGSTAMP: @@ -1853,9 +1873,8 @@ static int atalk_ioctl(struct socket *sock,unsigned int cmd, unsigned long arg) case SIOCGIFBRDADDR: case SIOCATALKDIFADDR: case SIOCDIFADDR: - case SIOCSARP: /* proxy AARP */ - case SIOCDARP: /* proxy AARP */ - { + case SIOCSARP: /* proxy AARP */ + case SIOCDARP: { /* proxy AARP */ int ret; rtnl_lock(); @@ -1877,7 +1896,7 @@ static int atalk_ioctl(struct socket *sock,unsigned int cmd, unsigned long arg) case SIOCGIFCOUNT: case SIOCGIFINDEX: case SIOCGIFNAME: - return dev_ioctl(cmd,(void *) arg); + return dev_ioctl(cmd, (void *)arg); case SIOCSIFMETRIC: case SIOCSIFBRDADDR: case SIOCGIFNETMASK: @@ -1895,61 +1914,48 @@ static int atalk_ioctl(struct socket *sock,unsigned int cmd, unsigned long arg) } static struct net_proto_family atalk_family_ops = { - family: PF_APPLETALK, - create: atalk_create, + .family = PF_APPLETALK, + .create = atalk_create, }; -static struct proto_ops SOCKOPS_WRAPPED(atalk_dgram_ops)= -{ - family: PF_APPLETALK, - - release: atalk_release, - bind: atalk_bind, - connect: atalk_connect, - socketpair: sock_no_socketpair, - accept: sock_no_accept, - getname: atalk_getname, - poll: datagram_poll, - ioctl: atalk_ioctl, - listen: sock_no_listen, - shutdown: sock_no_shutdown, - setsockopt: sock_no_setsockopt, - getsockopt: sock_no_getsockopt, - sendmsg: atalk_sendmsg, - recvmsg: atalk_recvmsg, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, +static struct proto_ops SOCKOPS_WRAPPED(atalk_dgram_ops) = { + .family = PF_APPLETALK, + .release = atalk_release, + .bind = atalk_bind, + .connect = atalk_connect, + .socketpair = sock_no_socketpair, + .accept = sock_no_accept, + .getname = atalk_getname, + .poll = datagram_poll, + .ioctl = atalk_ioctl, + .listen = sock_no_listen, + .shutdown = sock_no_shutdown, + .setsockopt = sock_no_setsockopt, + .getsockopt = sock_no_getsockopt, + .sendmsg = atalk_sendmsg, + .recvmsg = atalk_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; #include <linux/smp_lock.h> SOCKOPS_WRAP(atalk_dgram, PF_APPLETALK); -static struct notifier_block ddp_notifier= -{ - ddp_device_event, - NULL, - 0 +static struct notifier_block ddp_notifier = { + .notifier_call = ddp_device_event, }; -struct packet_type ltalk_packet_type= -{ - 0, - NULL, - ltalk_rcv, - NULL, - NULL +struct packet_type ltalk_packet_type = { + .type = __constant_htons(ETH_P_LOCALTALK), + .func = ltalk_rcv, }; -struct packet_type ppptalk_packet_type= -{ - 0, - NULL, - atalk_rcv, - NULL, - NULL +struct packet_type ppptalk_packet_type = { + .type = __constant_htons(ETH_P_PPPTALK), + .func = atalk_rcv, }; -static char ddp_snap_id[] = {0x08, 0x00, 0x07, 0x80, 0x9B}; +static char ddp_snap_id[] = { 0x08, 0x00, 0x07, 0x80, 0x9B }; /* Export symbols for use by drivers when AppleTalk is a module */ EXPORT_SYMBOL(aarp_send_ddp); @@ -1959,15 +1965,12 @@ EXPORT_SYMBOL(atalk_find_dev_addr); /* Called by proto.c on kernel start up */ static int __init atalk_init(void) { - (void) sock_register(&atalk_family_ops); + (void)sock_register(&atalk_family_ops); ddp_dl = register_snap_client(ddp_snap_id, atalk_rcv); if (!ddp_dl) printk(KERN_CRIT "Unable to register DDP with SNAP.\n"); - ltalk_packet_type.type = htons(ETH_P_LOCALTALK); dev_add_pack(<alk_packet_type); - - ppptalk_packet_type.type = htons(ETH_P_PPPTALK); dev_add_pack(&ppptalk_packet_type); register_netdevice_notifier(&ddp_notifier); diff --git a/net/appletalk/sysctl_net_atalk.c b/net/appletalk/sysctl_net_atalk.c index 8d9fe232ed9f..663df18c826a 100644 --- a/net/appletalk/sysctl_net_atalk.c +++ b/net/appletalk/sysctl_net_atalk.c @@ -1,4 +1,4 @@ -/* -*- linux-c -*- +/* * sysctl_net_atalk.c: sysctl interface to net AppleTalk subsystem. * * Begun April 1, 1996, Mike Shaver. @@ -17,25 +17,59 @@ extern int sysctl_aarp_resolve_time; #ifdef CONFIG_SYSCTL static ctl_table atalk_table[] = { - {NET_ATALK_AARP_EXPIRY_TIME, "aarp-expiry-time", - &sysctl_aarp_expiry_time, sizeof(int), 0644, NULL, &proc_dointvec_jiffies}, - {NET_ATALK_AARP_TICK_TIME, "aarp-tick-time", - &sysctl_aarp_tick_time, sizeof(int), 0644, NULL, &proc_dointvec_jiffies}, - {NET_ATALK_AARP_RETRANSMIT_LIMIT, "aarp-retransmit-limit", - &sysctl_aarp_retransmit_limit, sizeof(int), 0644, NULL, &proc_dointvec}, - {NET_ATALK_AARP_RESOLVE_TIME, "aarp-resolve-time", - &sysctl_aarp_resolve_time, sizeof(int), 0644, NULL, &proc_dointvec_jiffies}, - {0} + { + .ctl_name = NET_ATALK_AARP_EXPIRY_TIME, + .procname = "aarp-expiry-time", + .data = &sysctl_aarp_expiry_time, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec_jiffies, + }, + { + .ctl_name = NET_ATALK_AARP_TICK_TIME, + .procname = "aarp-tick-time", + .data = &sysctl_aarp_tick_time, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec_jiffies, + }, + { + .ctl_name = NET_ATALK_AARP_RETRANSMIT_LIMIT, + .procname = "aarp-retransmit-limit", + .data = &sysctl_aarp_retransmit_limit, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, + { + .ctl_name = NET_ATALK_AARP_RESOLVE_TIME, + .procname = "aarp-resolve-time", + .data = &sysctl_aarp_resolve_time, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec_jiffies, + }, + { 0 }, }; static ctl_table atalk_dir_table[] = { - {NET_ATALK, "appletalk", NULL, 0, 0555, atalk_table}, - {0} + { + .ctl_name = NET_ATALK, + .procname = "appletalk", + .mode = 0555, + .child = atalk_table, + }, + { 0 }, }; static ctl_table atalk_root_table[] = { - {CTL_NET, "net", NULL, 0, 0555, atalk_dir_table}, - {0} + { + .ctl_name = CTL_NET, + .procname = "net", + .mode = 0555, + .child = atalk_dir_table, + }, + { 0 }, }; static struct ctl_table_header *atalk_table_header; diff --git a/net/atm/clip.c b/net/atm/clip.c index 3ae5ae8757aa..96013cb4c0e5 100644 --- a/net/atm/clip.c +++ b/net/atm/clip.c @@ -274,14 +274,14 @@ static void clip_neigh_error(struct neighbour *neigh,struct sk_buff *skb) static struct neigh_ops clip_neigh_ops = { - family: AF_INET, - destructor: clip_neigh_destroy, - solicit: clip_neigh_solicit, - error_report: clip_neigh_error, - output: dev_queue_xmit, - connected_output: dev_queue_xmit, - hh_output: dev_queue_xmit, - queue_xmit: dev_queue_xmit, + .family = AF_INET, + .destructor = clip_neigh_destroy, + .solicit = clip_neigh_solicit, + .error_report = clip_neigh_error, + .output = dev_queue_xmit, + .connected_output = dev_queue_xmit, + .hh_output = dev_queue_xmit, + .queue_xmit = dev_queue_xmit, }; @@ -699,7 +699,7 @@ static void atmarpd_close(struct atm_vcc *vcc) static struct atmdev_ops atmarpd_dev_ops = { - close: atmarpd_close, + .close =atmarpd_close, }; diff --git a/net/atm/mpc.c b/net/atm/mpc.c index 66c4286eee72..513f008c8397 100644 --- a/net/atm/mpc.c +++ b/net/atm/mpc.c @@ -736,8 +736,8 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb) } static struct atmdev_ops mpc_ops = { /* only send is required */ - close: mpoad_close, - send: msg_from_mpoad + .close =mpoad_close, + .send = msg_from_mpoad }; static struct atm_dev mpc_dev = { diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c index fa4ecd64cc80..cd46ce110084 100644 --- a/net/atm/mpoa_proc.c +++ b/net/atm/mpoa_proc.c @@ -42,8 +42,8 @@ static int parse_qos(const char *buff, int len); * Define allowed FILE OPERATIONS */ static struct file_operations mpc_file_operations = { - read: proc_mpc_read, - write: proc_mpc_write, + .read = proc_mpc_read, + .write = proc_mpc_write, }; static int print_header(char *buff,struct mpoa_client *mpc){ diff --git a/net/atm/pppoatm.c b/net/atm/pppoatm.c index 5ec53e6a73ad..b9aa77392a80 100644 --- a/net/atm/pppoatm.c +++ b/net/atm/pppoatm.c @@ -266,8 +266,8 @@ static int pppoatm_devppp_ioctl(struct ppp_channel *chan, unsigned int cmd, } static /*const*/ struct ppp_channel_ops pppoatm_ops = { - start_xmit: pppoatm_send, - ioctl: pppoatm_devppp_ioctl, + .start_xmit = pppoatm_send, + .ioctl = pppoatm_devppp_ioctl, }; static int pppoatm_assign_vcc(struct atm_vcc *atmvcc, unsigned long arg) diff --git a/net/atm/proc.c b/net/atm/proc.c index bc11d58e7931..5839ebdf7aba 100644 --- a/net/atm/proc.c +++ b/net/atm/proc.c @@ -57,11 +57,11 @@ static ssize_t proc_spec_atm_read(struct file *file,char *buf,size_t count, loff_t *pos); static struct file_operations proc_dev_atm_operations = { - read: proc_dev_atm_read, + .read = proc_dev_atm_read, }; static struct file_operations proc_spec_atm_operations = { - read: proc_spec_atm_read, + .read = proc_spec_atm_read, }; static void add_stats(char *buf,const char *aal, diff --git a/net/atm/pvc.c b/net/atm/pvc.c index 5f83cd5e6c28..fd2a99bba4f6 100644 --- a/net/atm/pvc.c +++ b/net/atm/pvc.c @@ -78,24 +78,24 @@ static int pvc_getname(struct socket *sock,struct sockaddr *sockaddr, static struct proto_ops SOCKOPS_WRAPPED(pvc_proto_ops) = { - family: PF_ATMPVC, - - release: atm_release, - bind: pvc_bind, - connect: pvc_connect, - socketpair: sock_no_socketpair, - accept: sock_no_accept, - getname: pvc_getname, - poll: atm_poll, - ioctl: atm_ioctl, - listen: sock_no_listen, - shutdown: pvc_shutdown, - setsockopt: atm_setsockopt, - getsockopt: atm_getsockopt, - sendmsg: atm_sendmsg, - recvmsg: atm_recvmsg, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_ATMPVC, + + .release = atm_release, + .bind = pvc_bind, + .connect = pvc_connect, + .socketpair = sock_no_socketpair, + .accept = sock_no_accept, + .getname = pvc_getname, + .poll = atm_poll, + .ioctl = atm_ioctl, + .listen = sock_no_listen, + .shutdown = pvc_shutdown, + .setsockopt = atm_setsockopt, + .getsockopt = atm_getsockopt, + .sendmsg = atm_sendmsg, + .recvmsg = atm_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; @@ -111,8 +111,8 @@ static int pvc_create(struct socket *sock,int protocol) static struct net_proto_family pvc_family_ops = { - family: PF_ATMPVC, - create: pvc_create, + .family =PF_ATMPVC, + .create =pvc_create, }; diff --git a/net/atm/signaling.c b/net/atm/signaling.c index 2d27f200c901..03d9c88c0ff7 100644 --- a/net/atm/signaling.c +++ b/net/atm/signaling.c @@ -227,8 +227,8 @@ static void sigd_close(struct atm_vcc *vcc) static struct atmdev_ops sigd_dev_ops = { - close: sigd_close, - send: sigd_send + .close =sigd_close, + .send = sigd_send }; diff --git a/net/atm/svc.c b/net/atm/svc.c index cd00bc5befe5..fb9fc7d95397 100644 --- a/net/atm/svc.c +++ b/net/atm/svc.c @@ -391,24 +391,24 @@ static int svc_getsockopt(struct socket *sock,int level,int optname, static struct proto_ops SOCKOPS_WRAPPED(svc_proto_ops) = { - family: PF_ATMSVC, - - release: svc_release, - bind: svc_bind, - connect: svc_connect, - socketpair: sock_no_socketpair, - accept: svc_accept, - getname: svc_getname, - poll: atm_poll, - ioctl: atm_ioctl, - listen: svc_listen, - shutdown: svc_shutdown, - setsockopt: svc_setsockopt, - getsockopt: svc_getsockopt, - sendmsg: atm_sendmsg, - recvmsg: atm_recvmsg, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_ATMSVC, + + .release = svc_release, + .bind = svc_bind, + .connect = svc_connect, + .socketpair = sock_no_socketpair, + .accept = svc_accept, + .getname = svc_getname, + .poll = atm_poll, + .ioctl = atm_ioctl, + .listen = svc_listen, + .shutdown = svc_shutdown, + .setsockopt = svc_setsockopt, + .getsockopt = svc_getsockopt, + .sendmsg = atm_sendmsg, + .recvmsg = atm_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; @@ -430,8 +430,8 @@ static int svc_create(struct socket *sock,int protocol) static struct net_proto_family svc_family_ops = { - family: PF_ATMSVC, - create: svc_create, + .family =PF_ATMSVC, + .create =svc_create, }; diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 8bf321a41698..661335502baf 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -1810,29 +1810,29 @@ static int ax25_get_info(char *buffer, char **start, off_t offset, int length) } static struct net_proto_family ax25_family_ops = { - family: PF_AX25, - create: ax25_create, + .family = PF_AX25, + .create = ax25_create, }; static struct proto_ops SOCKOPS_WRAPPED(ax25_proto_ops) = { - family: PF_AX25, - - release: ax25_release, - bind: ax25_bind, - connect: ax25_connect, - socketpair: sock_no_socketpair, - accept: ax25_accept, - getname: ax25_getname, - poll: datagram_poll, - ioctl: ax25_ioctl, - listen: ax25_listen, - shutdown: ax25_shutdown, - setsockopt: ax25_setsockopt, - getsockopt: ax25_getsockopt, - sendmsg: ax25_sendmsg, - recvmsg: ax25_recvmsg, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_AX25, + + .release = ax25_release, + .bind = ax25_bind, + .connect = ax25_connect, + .socketpair = sock_no_socketpair, + .accept = ax25_accept, + .getname = ax25_getname, + .poll = datagram_poll, + .ioctl = ax25_ioctl, + .listen = ax25_listen, + .shutdown = ax25_shutdown, + .setsockopt = ax25_setsockopt, + .getsockopt = ax25_getsockopt, + .sendmsg = ax25_sendmsg, + .recvmsg = ax25_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; #include <linux/smp_lock.h> @@ -1842,12 +1842,12 @@ SOCKOPS_WRAP(ax25_proto, PF_AX25); * Called by socket.c on kernel start up */ static struct packet_type ax25_packet_type = { - type: __constant_htons(ETH_P_AX25), - func: ax25_kiss_rcv, + .type = __constant_htons(ETH_P_AX25), + .func = ax25_kiss_rcv, }; static struct notifier_block ax25_dev_notifier = { - notifier_call: ax25_device_event, + .notifier_call =ax25_device_event, }; EXPORT_SYMBOL(ax25_encapsulate); diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index f5ee87d70574..682c84c1623f 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -80,7 +80,7 @@ static struct hci_sec_filter hci_sec_filter = { }; static struct bluez_sock_list hci_sk_list = { - lock: RW_LOCK_UNLOCKED + .lock = RW_LOCK_UNLOCKED }; /* Send frame to RAW socket */ @@ -522,22 +522,22 @@ int hci_sock_getsockopt(struct socket *sock, int level, int optname, char *optva } struct proto_ops hci_sock_ops = { - family: PF_BLUETOOTH, - release: hci_sock_release, - bind: hci_sock_bind, - getname: hci_sock_getname, - sendmsg: hci_sock_sendmsg, - recvmsg: hci_sock_recvmsg, - ioctl: hci_sock_ioctl, - poll: datagram_poll, - listen: sock_no_listen, - shutdown: sock_no_shutdown, - setsockopt: hci_sock_setsockopt, - getsockopt: hci_sock_getsockopt, - connect: sock_no_connect, - socketpair: sock_no_socketpair, - accept: sock_no_accept, - mmap: sock_no_mmap + .family = PF_BLUETOOTH, + .release = hci_sock_release, + .bind = hci_sock_bind, + .getname = hci_sock_getname, + .sendmsg = hci_sock_sendmsg, + .recvmsg = hci_sock_recvmsg, + .ioctl = hci_sock_ioctl, + .poll = datagram_poll, + .listen = sock_no_listen, + .shutdown = sock_no_shutdown, + .setsockopt = hci_sock_setsockopt, + .getsockopt = hci_sock_getsockopt, + .connect = sock_no_connect, + .socketpair = sock_no_socketpair, + .accept = sock_no_accept, + .mmap = sock_no_mmap }; static int hci_sock_create(struct socket *sock, int protocol) @@ -600,12 +600,12 @@ static int hci_sock_dev_event(struct notifier_block *this, unsigned long event, } struct net_proto_family hci_sock_family_ops = { - family: PF_BLUETOOTH, - create: hci_sock_create + .family = PF_BLUETOOTH, + .create = hci_sock_create }; struct notifier_block hci_sock_nblock = { - notifier_call: hci_sock_dev_event + .notifier_call = hci_sock_dev_event }; int hci_sock_init(void) diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index 7eb6e1e7314c..015cc3f06c8a 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c @@ -64,7 +64,7 @@ static struct proto_ops l2cap_sock_ops; struct bluez_sock_list l2cap_sk_list = { - lock: RW_LOCK_UNLOCKED + .lock = RW_LOCK_UNLOCKED }; static int l2cap_conn_del(struct hci_conn *conn, int err); @@ -1973,38 +1973,38 @@ static int l2cap_read_proc(char *buf, char **start, off_t offset, int count, int } static struct proto_ops l2cap_sock_ops = { - family: PF_BLUETOOTH, - release: l2cap_sock_release, - bind: l2cap_sock_bind, - connect: l2cap_sock_connect, - listen: l2cap_sock_listen, - accept: l2cap_sock_accept, - getname: l2cap_sock_getname, - sendmsg: l2cap_sock_sendmsg, - recvmsg: bluez_sock_recvmsg, - poll: bluez_sock_poll, - socketpair: sock_no_socketpair, - ioctl: sock_no_ioctl, - shutdown: sock_no_shutdown, - setsockopt: l2cap_sock_setsockopt, - getsockopt: l2cap_sock_getsockopt, - mmap: sock_no_mmap + .family = PF_BLUETOOTH, + .release = l2cap_sock_release, + .bind = l2cap_sock_bind, + .connect = l2cap_sock_connect, + .listen = l2cap_sock_listen, + .accept = l2cap_sock_accept, + .getname = l2cap_sock_getname, + .sendmsg = l2cap_sock_sendmsg, + .recvmsg = bluez_sock_recvmsg, + .poll = bluez_sock_poll, + .socketpair = sock_no_socketpair, + .ioctl = sock_no_ioctl, + .shutdown = sock_no_shutdown, + .setsockopt = l2cap_sock_setsockopt, + .getsockopt = l2cap_sock_getsockopt, + .mmap = sock_no_mmap }; static struct net_proto_family l2cap_sock_family_ops = { - family: PF_BLUETOOTH, - create: l2cap_sock_create + .family = PF_BLUETOOTH, + .create = l2cap_sock_create }; static struct hci_proto l2cap_hci_proto = { - name: "L2CAP", - id: HCI_PROTO_L2CAP, - connect_ind: l2cap_connect_ind, - connect_cfm: l2cap_connect_cfm, - disconn_ind: l2cap_disconn_ind, - recv_acldata: l2cap_recv_acldata, - auth_cfm: l2cap_auth_cfm, - encrypt_cfm: l2cap_encrypt_cfm + .name = "L2CAP", + .id = HCI_PROTO_L2CAP, + .connect_ind = l2cap_connect_ind, + .connect_cfm = l2cap_connect_cfm, + .disconn_ind = l2cap_disconn_ind, + .recv_acldata = l2cap_recv_acldata, + .auth_cfm = l2cap_auth_cfm, + .encrypt_cfm = l2cap_encrypt_cfm }; int __init l2cap_init(void) diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 064b1a32a053..eb0ef4a11766 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -64,7 +64,7 @@ static struct proto_ops sco_sock_ops; static struct bluez_sock_list sco_sk_list = { - lock: RW_LOCK_UNLOCKED + .lock = RW_LOCK_UNLOCKED }; static inline int sco_chan_add(struct sco_conn *conn, struct sock *sk, struct sock *parent); @@ -936,36 +936,36 @@ static int sco_read_proc(char *buf, char **start, off_t offset, int count, int * } static struct proto_ops sco_sock_ops = { - family: PF_BLUETOOTH, - release: sco_sock_release, - bind: sco_sock_bind, - connect: sco_sock_connect, - listen: sco_sock_listen, - accept: sco_sock_accept, - getname: sco_sock_getname, - sendmsg: sco_sock_sendmsg, - recvmsg: bluez_sock_recvmsg, - poll: bluez_sock_poll, - socketpair: sock_no_socketpair, - ioctl: sock_no_ioctl, - shutdown: sock_no_shutdown, - setsockopt: sco_sock_setsockopt, - getsockopt: sco_sock_getsockopt, - mmap: sock_no_mmap + .family = PF_BLUETOOTH, + .release = sco_sock_release, + .bind = sco_sock_bind, + .connect = sco_sock_connect, + .listen = sco_sock_listen, + .accept = sco_sock_accept, + .getname = sco_sock_getname, + .sendmsg = sco_sock_sendmsg, + .recvmsg = bluez_sock_recvmsg, + .poll = bluez_sock_poll, + .socketpair = sock_no_socketpair, + .ioctl = sock_no_ioctl, + .shutdown = sock_no_shutdown, + .setsockopt = sco_sock_setsockopt, + .getsockopt = sco_sock_getsockopt, + .mmap = sock_no_mmap }; static struct net_proto_family sco_sock_family_ops = { - family: PF_BLUETOOTH, - create: sco_sock_create + .family = PF_BLUETOOTH, + .create = sco_sock_create }; static struct hci_proto sco_hci_proto = { - name: "SCO", - id: HCI_PROTO_SCO, - connect_ind: sco_connect_ind, - connect_cfm: sco_connect_cfm, - disconn_ind: sco_disconn_ind, - recv_scodata: sco_recv_scodata, + .name = "SCO", + .id = HCI_PROTO_SCO, + .connect_ind = sco_connect_ind, + .connect_cfm = sco_connect_cfm, + .disconn_ind = sco_disconn_ind, + .recv_scodata = sco_recv_scodata, }; int __init sco_init(void) diff --git a/net/core/datagram.c b/net/core/datagram.c index ece74de9d1ca..f588cf30eae1 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c @@ -204,8 +204,8 @@ void skb_free_datagram(struct sock *sk, struct sk_buff *skb) int skb_copy_datagram(const struct sk_buff *skb, int offset, char *to, int size) { struct iovec iov = { - iov_base: to, - iov_len: size, + .iov_base = to, + .iov_len =size, }; return skb_copy_datagram_iovec(skb, offset, &iov, size); diff --git a/net/core/dev.c b/net/core/dev.c index c9166681c226..d71381bcf455 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2427,13 +2427,13 @@ static int dev_boot_phase = 1; * will not get the same name. */ -static int net_dev_init(void); - int register_netdevice(struct net_device *dev) { struct net_device *d, **dp; int ret; + BUG_ON(dev_boot_phase); + spin_lock_init(&dev->queue_lock); spin_lock_init(&dev->xmit_lock); dev->xmit_lock_owner = -1; @@ -2441,9 +2441,6 @@ int register_netdevice(struct net_device *dev) dev->fastpath_lock = RW_LOCK_UNLOCKED; #endif - if (dev_boot_phase) - net_dev_init(); - #ifdef CONFIG_NET_DIVERT ret = alloc_divert_blk(dev); if (ret) @@ -2552,6 +2549,8 @@ int unregister_netdevice(struct net_device *dev) unsigned long now, warning_time; struct net_device *d, **dp; + BUG_ON(dev_boot_phase); + /* If device is running, close it first. */ if (dev->flags & IFF_UP) dev_close(dev); @@ -2578,26 +2577,25 @@ int unregister_netdevice(struct net_device *dev) br_write_lock_bh(BR_NETPROTO_LOCK); br_write_unlock_bh(BR_NETPROTO_LOCK); - if (!dev_boot_phase) { + #ifdef CONFIG_NET_FASTROUTE - dev_clear_fastroute(dev); + dev_clear_fastroute(dev); #endif - /* Shutdown queueing discipline. */ - dev_shutdown(dev); - - net_run_sbin_hotplug(dev, "unregister"); - - /* Notify protocols, that we are about to destroy - this device. They should clean all the things. - */ - notifier_call_chain(&netdev_chain, NETDEV_UNREGISTER, dev); - - /* - * Flush the multicast chain - */ - dev_mc_discard(dev); - } + /* Shutdown queueing discipline. */ + dev_shutdown(dev); + + net_run_sbin_hotplug(dev, "unregister"); + + /* Notify protocols, that we are about to destroy + this device. They should clean all the things. + */ + notifier_call_chain(&netdev_chain, NETDEV_UNREGISTER, dev); + + /* + * Flush the multicast chain + */ + dev_mc_discard(dev); if (dev->uninit) dev->uninit(dev); @@ -2690,17 +2688,15 @@ extern void dv_init(void); /* - * Callers must hold the rtnl semaphore. See the comment at the - * end of Space.c for details about the locking. + * This is called single threaded during boot, so no need + * to take the rtnl semaphore. */ static int __init net_dev_init(void) { struct net_device *dev, **dp; int i; - if (!dev_boot_phase) - return 0; - + BUG_ON(!dev_boot_phase); #ifdef CONFIG_NET_DIVERT dv_init(); @@ -2834,7 +2830,7 @@ static int __init net_dev_init(void) return 0; } -__initcall(net_dev_init); +subsys_initcall(net_dev_init); #ifdef CONFIG_HOTPLUG diff --git a/net/core/ext8022.c b/net/core/ext8022.c index e6415d51accb..a5229fa7f262 100644 --- a/net/core/ext8022.c +++ b/net/core/ext8022.c @@ -25,12 +25,12 @@ static func_type llc_sap_table[128]; static int llc_users; static struct packet_type llc_packet_type = { - type: __constant_htons(ETH_P_802_2), - func: llc_rcv, + .type = __constant_htons(ETH_P_802_2), + .func = llc_rcv, }; static struct packet_type llc_tr_packet_type = { - type: __constant_htons(ETH_P_TR_802_2), - func: llc_rcv, + .type = __constant_htons(ETH_P_TR_802_2), + .func = llc_rcv, }; static int llc_rcv(struct sk_buff *skb, struct net_device *dev, diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 9ebda3e92bc8..8fd802a39be6 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -1471,143 +1471,143 @@ struct neigh_sysctl_table { ctl_table neigh_proto_dir[2]; ctl_table neigh_root_dir[2]; } neigh_sysctl_template = { - neigh_vars: { + .neigh_vars = { { - ctl_name: NET_NEIGH_MCAST_SOLICIT, - procname: "mcast_solicit", - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_NEIGH_MCAST_SOLICIT, + .procname = "mcast_solicit", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_NEIGH_UCAST_SOLICIT, - procname: "ucast_solicit", - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_NEIGH_UCAST_SOLICIT, + .procname = "ucast_solicit", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_NEIGH_APP_SOLICIT, - procname: "app_solicit", - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_NEIGH_APP_SOLICIT, + .procname = "app_solicit", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_NEIGH_RETRANS_TIME, - procname: "retrans_time", - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_NEIGH_RETRANS_TIME, + .procname = "retrans_time", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_NEIGH_REACHABLE_TIME, - procname: "base_reachable_time", - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec_jiffies, + .ctl_name = NET_NEIGH_REACHABLE_TIME, + .procname = "base_reachable_time", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec_jiffies, }, { - ctl_name: NET_NEIGH_DELAY_PROBE_TIME, - procname: "delay_first_probe_time", - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec_jiffies, + .ctl_name = NET_NEIGH_DELAY_PROBE_TIME, + .procname = "delay_first_probe_time", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec_jiffies, }, { - ctl_name: NET_NEIGH_GC_STALE_TIME, - procname: "gc_stale_time", - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec_jiffies, + .ctl_name = NET_NEIGH_GC_STALE_TIME, + .procname = "gc_stale_time", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec_jiffies, }, { - ctl_name: NET_NEIGH_UNRES_QLEN, - procname: "unres_qlen", - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_NEIGH_UNRES_QLEN, + .procname = "unres_qlen", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_NEIGH_PROXY_QLEN, - procname: "proxy_qlen", - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_NEIGH_PROXY_QLEN, + .procname = "proxy_qlen", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_NEIGH_ANYCAST_DELAY, - procname: "anycast_delay", - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_NEIGH_ANYCAST_DELAY, + .procname = "anycast_delay", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_NEIGH_PROXY_DELAY, - procname: "proxy_delay", - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_NEIGH_PROXY_DELAY, + .procname = "proxy_delay", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_NEIGH_LOCKTIME, - procname: "locktime", - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_NEIGH_LOCKTIME, + .procname = "locktime", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_NEIGH_GC_INTERVAL, - procname: "gc_interval", - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec_jiffies, + .ctl_name = NET_NEIGH_GC_INTERVAL, + .procname = "gc_interval", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec_jiffies, }, { - ctl_name: NET_NEIGH_GC_THRESH1, - procname: "gc_thresh1", - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_NEIGH_GC_THRESH1, + .procname = "gc_thresh1", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_NEIGH_GC_THRESH2, - procname: "gc_thresh2", - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_NEIGH_GC_THRESH2, + .procname = "gc_thresh2", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_NEIGH_GC_THRESH3, - procname: "gc_thresh3", - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_NEIGH_GC_THRESH3, + .procname = "gc_thresh3", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, }, - neigh_dev: { + .neigh_dev = { { - ctl_name: NET_PROTO_CONF_DEFAULT, - procname: "default", - mode: 0555, + .ctl_name = NET_PROTO_CONF_DEFAULT, + .procname = "default", + .mode = 0555, }, }, - neigh_neigh_dir: { + .neigh_neigh_dir = { { - procname: "neigh", - mode: 0555, + .procname = "neigh", + .mode = 0555, }, }, - neigh_proto_dir: { + .neigh_proto_dir = { { - mode: 0555, + .mode = 0555, }, }, - neigh_root_dir: { + .neigh_root_dir = { { - ctl_name: CTL_NET, - procname: "net", - mode: 0555, + .ctl_name = CTL_NET, + .procname = "net", + .mode = 0555, }, }, }; diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index bd6284c35d40..113d8d8a02f5 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c @@ -2098,16 +2098,16 @@ static int dn_device_event(struct notifier_block *this, unsigned long event, } static struct notifier_block dn_dev_notifier = { - notifier_call: dn_device_event, + .notifier_call =dn_device_event, }; extern int dn_route_rcv(struct sk_buff *, struct net_device *, struct packet_type *); static struct packet_type dn_dix_packet_type = { - type: __constant_htons(ETH_P_DNA_RT), - dev: NULL, /* All devices */ - func: dn_route_rcv, - data: (void*)1, + .type = __constant_htons(ETH_P_DNA_RT), + .dev = NULL, /* All devices */ + .func = dn_route_rcv, + .data = (void*)1, }; #define IS_NOT_PRINTABLE(x) ((x) < 32 || (x) > 126) @@ -2196,29 +2196,29 @@ static int dn_get_info(char *buffer, char **start, off_t offset, int length) static struct net_proto_family dn_family_ops = { - family: AF_DECnet, - create: dn_create, + .family = AF_DECnet, + .create = dn_create, }; static struct proto_ops dn_proto_ops = { - family: AF_DECnet, - - release: dn_release, - bind: dn_bind, - connect: dn_connect, - socketpair: sock_no_socketpair, - accept: dn_accept, - getname: dn_getname, - poll: dn_poll, - ioctl: dn_ioctl, - listen: dn_listen, - shutdown: dn_shutdown, - setsockopt: dn_setsockopt, - getsockopt: dn_getsockopt, - sendmsg: dn_sendmsg, - recvmsg: dn_recvmsg, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = AF_DECnet, + + .release = dn_release, + .bind = dn_bind, + .connect = dn_connect, + .socketpair = sock_no_socketpair, + .accept = dn_accept, + .getname = dn_getname, + .poll = dn_poll, + .ioctl = dn_ioctl, + .listen = dn_listen, + .shutdown = dn_shutdown, + .setsockopt = dn_setsockopt, + .getsockopt = dn_getsockopt, + .sendmsg = dn_sendmsg, + .recvmsg = dn_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; #ifdef CONFIG_SYSCTL diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c index ec9c8b07454f..989bcb931458 100644 --- a/net/decnet/dn_dev.c +++ b/net/decnet/dn_dev.c @@ -66,77 +66,77 @@ static void dn_send_ptp_hello(struct net_device *dev); static struct dn_dev_parms dn_dev_list[] = { { - type: ARPHRD_ETHER, /* Ethernet */ - mode: DN_DEV_BCAST, - state: DN_DEV_S_RU, - blksize: 1498, - t2: 1, - t3: 10, - name: "ethernet", - ctl_name: NET_DECNET_CONF_ETHER, - up: dn_eth_up, - timer3: dn_send_brd_hello, + .type = ARPHRD_ETHER, /* Ethernet */ + .mode = DN_DEV_BCAST, + .state = DN_DEV_S_RU, + .blksize = 1498, + .t2 = 1, + .t3 = 10, + .name = "ethernet", + .ctl_name = NET_DECNET_CONF_ETHER, + .up = dn_eth_up, + .timer3 = dn_send_brd_hello, }, { - type: ARPHRD_IPGRE, /* DECnet tunneled over GRE in IP */ - mode: DN_DEV_BCAST, - state: DN_DEV_S_RU, - blksize: 1400, - t2: 1, - t3: 10, - name: "ipgre", - ctl_name: NET_DECNET_CONF_GRE, - timer3: dn_send_brd_hello, + .type = ARPHRD_IPGRE, /* DECnet tunneled over GRE in IP */ + .mode = DN_DEV_BCAST, + .state = DN_DEV_S_RU, + .blksize = 1400, + .t2 = 1, + .t3 = 10, + .name = "ipgre", + .ctl_name = NET_DECNET_CONF_GRE, + .timer3 = dn_send_brd_hello, }, #if 0 { - type: ARPHRD_X25, /* Bog standard X.25 */ - mode: DN_DEV_UCAST, - state: DN_DEV_S_DS, - blksize: 230, - t2: 1, - t3: 120, - name: "x25", - ctl_name: NET_DECNET_CONF_X25, - timer3: dn_send_ptp_hello, + .type = ARPHRD_X25, /* Bog standard X.25 */ + .mode = DN_DEV_UCAST, + .state = DN_DEV_S_DS, + .blksize = 230, + .t2 = 1, + .t3 = 120, + .name = "x25", + .ctl_name = NET_DECNET_CONF_X25, + .timer3 = dn_send_ptp_hello, }, #endif #if 0 { - type: ARPHRD_PPP, /* DECnet over PPP */ - mode: DN_DEV_BCAST, - state: DN_DEV_S_RU, - blksize: 230, - t2: 1, - t3: 10, - name: "ppp", - ctl_name: NET_DECNET_CONF_PPP, - timer3: dn_send_brd_hello, + .type = ARPHRD_PPP, /* DECnet over PPP */ + .mode = DN_DEV_BCAST, + .state = DN_DEV_S_RU, + .blksize = 230, + .t2 = 1, + .t3 = 10, + .name = "ppp", + .ctl_name = NET_DECNET_CONF_PPP, + .timer3 = dn_send_brd_hello, }, #endif #if 0 { - type: ARPHRD_DDCMP, /* DECnet over DDCMP */ - mode: DN_DEV_UCAST, - state: DN_DEV_S_DS, - blksize: 230, - t2: 1, - t3: 120, - name: "ddcmp", - ctl_name: NET_DECNET_CONF_DDCMP, - timer3: dn_send_ptp_hello, + .type = ARPHRD_DDCMP, /* DECnet over DDCMP */ + .mode = DN_DEV_UCAST, + .state = DN_DEV_S_DS, + .blksize = 230, + .t2 = 1, + .t3 = 120, + .name = "ddcmp", + .ctl_name = NET_DECNET_CONF_DDCMP, + .timer3 = dn_send_ptp_hello, }, #endif { - type: ARPHRD_LOOPBACK, /* Loopback interface - always last */ - mode: DN_DEV_BCAST, - state: DN_DEV_S_RU, - blksize: 1498, - t2: 1, - t3: 10, - name: "loopback", - ctl_name: NET_DECNET_CONF_LOOPBACK, - timer3: dn_send_brd_hello, + .type = ARPHRD_LOOPBACK, /* Loopback interface - always last */ + .mode = DN_DEV_BCAST, + .state = DN_DEV_S_RU, + .blksize = 1498, + .t2 = 1, + .t3 = 10, + .name = "loopback", + .ctl_name = NET_DECNET_CONF_LOOPBACK, + .timer3 = dn_send_brd_hello, } }; diff --git a/net/decnet/dn_neigh.c b/net/decnet/dn_neigh.c index f25f37275ed6..2857bf2fc94c 100644 --- a/net/decnet/dn_neigh.c +++ b/net/decnet/dn_neigh.c @@ -54,66 +54,66 @@ static int dn_phase3_output(struct sk_buff *); * For talking to broadcast devices: Ethernet & PPP */ static struct neigh_ops dn_long_ops = { - family: AF_DECnet, - error_report: dn_long_error_report, - output: dn_long_output, - connected_output: dn_long_output, - hh_output: dev_queue_xmit, - queue_xmit: dev_queue_xmit, + .family = AF_DECnet, + .error_report = dn_long_error_report, + .output = dn_long_output, + .connected_output = dn_long_output, + .hh_output = dev_queue_xmit, + .queue_xmit = dev_queue_xmit, }; /* * For talking to pointopoint and multidrop devices: DDCMP and X.25 */ static struct neigh_ops dn_short_ops = { - family: AF_DECnet, - error_report: dn_short_error_report, - output: dn_short_output, - connected_output: dn_short_output, - hh_output: dev_queue_xmit, - queue_xmit: dev_queue_xmit, + .family = AF_DECnet, + .error_report = dn_short_error_report, + .output = dn_short_output, + .connected_output = dn_short_output, + .hh_output = dev_queue_xmit, + .queue_xmit = dev_queue_xmit, }; /* * For talking to DECnet phase III nodes */ static struct neigh_ops dn_phase3_ops = { - family: AF_DECnet, - error_report: dn_short_error_report, /* Can use short version here */ - output: dn_phase3_output, - connected_output: dn_phase3_output, - hh_output: dev_queue_xmit, - queue_xmit: dev_queue_xmit + .family = AF_DECnet, + .error_report = dn_short_error_report, /* Can use short version here */ + .output = dn_phase3_output, + .connected_output = dn_phase3_output, + .hh_output = dev_queue_xmit, + .queue_xmit = dev_queue_xmit }; struct neigh_table dn_neigh_table = { - family: PF_DECnet, - entry_size: sizeof(struct dn_neigh), - key_len: sizeof(dn_address), - hash: dn_neigh_hash, - constructor: dn_neigh_construct, - id: "dn_neigh_cache", - parms: { - tbl: &dn_neigh_table, - entries: 0, - base_reachable_time: 30 * HZ, - retrans_time: 1 * HZ, - gc_staletime: 60 * HZ, - reachable_time: 30 * HZ, - delay_probe_time: 5 * HZ, - queue_len: 3, - ucast_probes: 0, - app_probes: 0, - mcast_probes: 0, - anycast_delay: 0, - proxy_delay: 0, - proxy_qlen: 0, - locktime: 1 * HZ, + .family = PF_DECnet, + .entry_size = sizeof(struct dn_neigh), + .key_len = sizeof(dn_address), + .hash = dn_neigh_hash, + .constructor = dn_neigh_construct, + .id = "dn_neigh_cache", + .parms ={ + .tbl = &dn_neigh_table, + .entries = 0, + .base_reachable_time = 30 * HZ, + .retrans_time = 1 * HZ, + .gc_staletime = 60 * HZ, + .reachable_time = 30 * HZ, + .delay_probe_time = 5 * HZ, + .queue_len = 3, + .ucast_probes = 0, + .app_probes = 0, + .mcast_probes = 0, + .anycast_delay = 0, + .proxy_delay = 0, + .proxy_qlen = 0, + .locktime = 1 * HZ, }, - gc_interval: 30 * HZ, - gc_thresh1: 128, - gc_thresh2: 512, - gc_thresh3: 1024, + .gc_interval = 30 * HZ, + .gc_thresh1 = 128, + .gc_thresh2 = 512, + .gc_thresh3 = 1024, }; static u32 dn_neigh_hash(const void *pkey, const struct net_device *dev) diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c index ac798d824d44..49f28b21159c 100644 --- a/net/decnet/dn_route.c +++ b/net/decnet/dn_route.c @@ -112,16 +112,16 @@ static struct timer_list dn_rt_flush_timer = { function: dn_run_flush }; int decnet_dst_gc_interval = 2; static struct dst_ops dn_dst_ops = { - family: PF_DECnet, - protocol: __constant_htons(ETH_P_DNA_RT), - gc_thresh: 128, - gc: dn_dst_gc, - check: dn_dst_check, - reroute: dn_dst_reroute, - negative_advice: dn_dst_negative_advice, - link_failure: dn_dst_link_failure, - entry_size: sizeof(struct dn_route), - entries: ATOMIC_INIT(0), + .family = PF_DECnet, + .protocol = __constant_htons(ETH_P_DNA_RT), + .gc_thresh = 128, + .gc = dn_dst_gc, + .check = dn_dst_check, + .reroute = dn_dst_reroute, + .negative_advice = dn_dst_negative_advice, + .link_failure = dn_dst_link_failure, + .entry_size = sizeof(struct dn_route), + .entries = ATOMIC_INIT(0), }; static __inline__ unsigned dn_hash(unsigned short src, unsigned short dst) diff --git a/net/decnet/dn_rules.c b/net/decnet/dn_rules.c index b7d426e87ceb..d4c8db1d4162 100644 --- a/net/decnet/dn_rules.c +++ b/net/decnet/dn_rules.c @@ -58,10 +58,10 @@ struct dn_fib_rule }; static struct dn_fib_rule default_rule = { - r_clntref: ATOMIC_INIT(2), - r_preference: 0x7fff, - r_table: DN_DEFAULT_TABLE, - r_action: RTN_UNICAST + .r_clntref = ATOMIC_INIT(2), + .r_preference = 0x7fff, + .r_table = DN_DEFAULT_TABLE, + .r_action = RTN_UNICAST }; static struct dn_fib_rule *dn_fib_rules = &default_rule; @@ -296,7 +296,7 @@ static int dn_fib_rules_event(struct notifier_block *this, unsigned long event, static struct notifier_block dn_fib_rules_notifier = { - notifier_call: dn_fib_rules_event, + .notifier_call = dn_fib_rules_event, }; static int dn_fib_fill_rule(struct sk_buff *skb, struct dn_fib_rule *r, struct netlink_callback *cb) diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index 69b9d72b8fe4..1034945a82b3 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c @@ -697,29 +697,29 @@ static int econet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg } static struct net_proto_family econet_family_ops = { - family: PF_ECONET, - create: econet_create, + .family = PF_ECONET, + .create = econet_create, }; static struct proto_ops SOCKOPS_WRAPPED(econet_ops) = { - family: PF_ECONET, - - release: econet_release, - bind: econet_bind, - connect: sock_no_connect, - socketpair: sock_no_socketpair, - accept: sock_no_accept, - getname: econet_getname, - poll: datagram_poll, - ioctl: econet_ioctl, - listen: sock_no_listen, - shutdown: sock_no_shutdown, - setsockopt: sock_no_setsockopt, - getsockopt: sock_no_getsockopt, - sendmsg: econet_sendmsg, - recvmsg: econet_recvmsg, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_ECONET, + + .release = econet_release, + .bind = econet_bind, + .connect = sock_no_connect, + .socketpair = sock_no_socketpair, + .accept = sock_no_accept, + .getname = econet_getname, + .poll = datagram_poll, + .ioctl = econet_ioctl, + .listen = sock_no_listen, + .shutdown = sock_no_shutdown, + .setsockopt = sock_no_setsockopt, + .getsockopt = sock_no_getsockopt, + .sendmsg = econet_sendmsg, + .recvmsg = econet_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; #include <linux/smp_lock.h> @@ -1068,8 +1068,8 @@ static int econet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet } static struct packet_type econet_packet_type = { - type: __constant_htons(ETH_P_ECONET), - func: econet_rcv, + .type = __constant_htons(ETH_P_ECONET), + .func = econet_rcv, }; static void econet_hw_initialise(void) @@ -1103,7 +1103,7 @@ static int econet_notifier(struct notifier_block *this, unsigned long msg, void } static struct notifier_block econet_netdev_notifier = { - notifier_call: econet_notifier, + .notifier_call =econet_notifier, }; static void __exit econet_proto_exit(void) diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 57e7f5e83b67..50beeb9a9e32 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -972,50 +972,50 @@ static int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) } struct proto_ops inet_stream_ops = { - family: PF_INET, - - release: inet_release, - bind: inet_bind, - connect: inet_stream_connect, - socketpair: sock_no_socketpair, - accept: inet_accept, - getname: inet_getname, - poll: tcp_poll, - ioctl: inet_ioctl, - listen: inet_listen, - shutdown: inet_shutdown, - setsockopt: inet_setsockopt, - getsockopt: inet_getsockopt, - sendmsg: inet_sendmsg, - recvmsg: inet_recvmsg, - mmap: sock_no_mmap, - sendpage: tcp_sendpage + .family = PF_INET, + + .release = inet_release, + .bind = inet_bind, + .connect = inet_stream_connect, + .socketpair = sock_no_socketpair, + .accept = inet_accept, + .getname = inet_getname, + .poll = tcp_poll, + .ioctl = inet_ioctl, + .listen = inet_listen, + .shutdown = inet_shutdown, + .setsockopt = inet_setsockopt, + .getsockopt = inet_getsockopt, + .sendmsg = inet_sendmsg, + .recvmsg = inet_recvmsg, + .mmap = sock_no_mmap, + .sendpage = tcp_sendpage }; struct proto_ops inet_dgram_ops = { - family: PF_INET, - - release: inet_release, - bind: inet_bind, - connect: inet_dgram_connect, - socketpair: sock_no_socketpair, - accept: sock_no_accept, - getname: inet_getname, - poll: datagram_poll, - ioctl: inet_ioctl, - listen: sock_no_listen, - shutdown: inet_shutdown, - setsockopt: inet_setsockopt, - getsockopt: inet_getsockopt, - sendmsg: inet_sendmsg, - recvmsg: inet_recvmsg, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_INET, + + .release = inet_release, + .bind = inet_bind, + .connect = inet_dgram_connect, + .socketpair = sock_no_socketpair, + .accept = sock_no_accept, + .getname = inet_getname, + .poll = datagram_poll, + .ioctl = inet_ioctl, + .listen = sock_no_listen, + .shutdown = inet_shutdown, + .setsockopt = inet_setsockopt, + .getsockopt = inet_getsockopt, + .sendmsg = inet_sendmsg, + .recvmsg = inet_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; struct net_proto_family inet_family_ops = { - family: PF_INET, - create: inet_create, + .family = PF_INET, + .create = inet_create, }; @@ -1028,34 +1028,34 @@ extern void tcp_v4_init(struct net_proto_family *); static struct inet_protosw inetsw_array[] = { { - type: SOCK_STREAM, - protocol: IPPROTO_TCP, - prot: &tcp_prot, - ops: &inet_stream_ops, - capability: -1, - no_check: 0, - flags: INET_PROTOSW_PERMANENT, + .type = SOCK_STREAM, + .protocol = IPPROTO_TCP, + .prot = &tcp_prot, + .ops = &inet_stream_ops, + .capability = -1, + .no_check = 0, + .flags = INET_PROTOSW_PERMANENT, }, { - type: SOCK_DGRAM, - protocol: IPPROTO_UDP, - prot: &udp_prot, - ops: &inet_dgram_ops, - capability: -1, - no_check: UDP_CSUM_DEFAULT, - flags: INET_PROTOSW_PERMANENT, + .type = SOCK_DGRAM, + .protocol = IPPROTO_UDP, + .prot = &udp_prot, + .ops = &inet_dgram_ops, + .capability = -1, + .no_check = UDP_CSUM_DEFAULT, + .flags = INET_PROTOSW_PERMANENT, }, { - type: SOCK_RAW, - protocol: IPPROTO_IP, /* wild card */ - prot: &raw_prot, - ops: &inet_dgram_ops, - capability: CAP_NET_RAW, - no_check: UDP_CSUM_DEFAULT, - flags: INET_PROTOSW_REUSE, + .type = SOCK_RAW, + .protocol = IPPROTO_IP, /* wild card */ + .prot = &raw_prot, + .ops = &inet_dgram_ops, + .capability = CAP_NET_RAW, + .no_check = UDP_CSUM_DEFAULT, + .flags = INET_PROTOSW_REUSE, } }; diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index f66b8220474b..a24265d561e5 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -124,70 +124,70 @@ static void arp_error_report(struct neighbour *neigh, struct sk_buff *skb); static void parp_redo(struct sk_buff *skb); static struct neigh_ops arp_generic_ops = { - family: AF_INET, - solicit: arp_solicit, - error_report: arp_error_report, - output: neigh_resolve_output, - connected_output: neigh_connected_output, - hh_output: dev_queue_xmit, - queue_xmit: dev_queue_xmit, + .family = AF_INET, + .solicit = arp_solicit, + .error_report = arp_error_report, + .output = neigh_resolve_output, + .connected_output = neigh_connected_output, + .hh_output = dev_queue_xmit, + .queue_xmit = dev_queue_xmit, }; static struct neigh_ops arp_hh_ops = { - family: AF_INET, - solicit: arp_solicit, - error_report: arp_error_report, - output: neigh_resolve_output, - connected_output: neigh_resolve_output, - hh_output: dev_queue_xmit, - queue_xmit: dev_queue_xmit, + .family = AF_INET, + .solicit = arp_solicit, + .error_report = arp_error_report, + .output = neigh_resolve_output, + .connected_output = neigh_resolve_output, + .hh_output = dev_queue_xmit, + .queue_xmit = dev_queue_xmit, }; static struct neigh_ops arp_direct_ops = { - family: AF_INET, - output: dev_queue_xmit, - connected_output: dev_queue_xmit, - hh_output: dev_queue_xmit, - queue_xmit: dev_queue_xmit, + .family = AF_INET, + .output = dev_queue_xmit, + .connected_output = dev_queue_xmit, + .hh_output = dev_queue_xmit, + .queue_xmit = dev_queue_xmit, }; struct neigh_ops arp_broken_ops = { - family: AF_INET, - solicit: arp_solicit, - error_report: arp_error_report, - output: neigh_compat_output, - connected_output: neigh_compat_output, - hh_output: dev_queue_xmit, - queue_xmit: dev_queue_xmit, + .family = AF_INET, + .solicit = arp_solicit, + .error_report = arp_error_report, + .output = neigh_compat_output, + .connected_output = neigh_compat_output, + .hh_output = dev_queue_xmit, + .queue_xmit = dev_queue_xmit, }; struct neigh_table arp_tbl = { - family: AF_INET, - entry_size: sizeof(struct neighbour) + 4, - key_len: 4, - hash: arp_hash, - constructor: arp_constructor, - proxy_redo: parp_redo, - id: "arp_cache", - parms: { - tbl: &arp_tbl, - base_reachable_time: 30 * HZ, - retrans_time: 1 * HZ, - gc_staletime: 60 * HZ, - reachable_time: 30 * HZ, - delay_probe_time: 5 * HZ, - queue_len: 3, - ucast_probes: 3, - mcast_probes: 3, - anycast_delay: 1 * HZ, - proxy_delay: (8 * HZ) / 10, - proxy_qlen: 64, - locktime: 1 * HZ, + .family = AF_INET, + .entry_size = sizeof(struct neighbour) + 4, + .key_len = 4, + .hash = arp_hash, + .constructor = arp_constructor, + .proxy_redo = parp_redo, + .id = "arp_cache", + .parms = { + .tbl = &arp_tbl, + .base_reachable_time = 30 * HZ, + .retrans_time = 1 * HZ, + .gc_staletime = 60 * HZ, + .reachable_time = 30 * HZ, + .delay_probe_time = 5 * HZ, + .queue_len = 3, + .ucast_probes = 3, + .mcast_probes = 3, + .anycast_delay = 1 * HZ, + .proxy_delay = (8 * HZ) / 10, + .proxy_qlen = 64, + .locktime = 1 * HZ, }, - gc_interval: 30 * HZ, - gc_thresh1: 128, - gc_thresh2: 512, - gc_thresh3: 1024, + .gc_interval = 30 * HZ, + .gc_thresh1 = 128, + .gc_thresh2 = 512, + .gc_thresh3 = 1024, }; int arp_mc_map(u32 addr, u8 *haddr, struct net_device *dev, int dir) @@ -1180,9 +1180,9 @@ void arp_ifdown(struct net_device *dev) */ static struct packet_type arp_packet_type = { - type: __constant_htons(ETH_P_ARP), - func: arp_rcv, - data: (void*) 1, /* understand shared skbs */ + .type = __constant_htons(ETH_P_ARP), + .func = arp_rcv, + .data = (void*) 1, /* understand shared skbs */ }; void __init arp_init (void) diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index d831f67bc850..306b15efaa9f 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -62,18 +62,18 @@ #include <net/ip_fib.h> struct ipv4_devconf ipv4_devconf = { - accept_redirects: 1, - send_redirects: 1, - secure_redirects: 1, - shared_media: 1, + .accept_redirects = 1, + .send_redirects = 1, + .secure_redirects = 1, + .shared_media = 1, }; static struct ipv4_devconf ipv4_devconf_dflt = { - accept_redirects: 1, - send_redirects: 1, - secure_redirects: 1, - shared_media: 1, - accept_source_route: 1, + .accept_redirects = 1, + .send_redirects = 1, + .secure_redirects = 1, + .shared_media = 1, + .accept_source_route = 1, }; static void rtmsg_ifa(int event, struct in_ifaddr *); @@ -886,7 +886,7 @@ out: } struct notifier_block ip_netdev_notifier = { - notifier_call: inetdev_event, + .notifier_call =inetdev_event, }; static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa, @@ -1047,150 +1047,150 @@ static struct devinet_sysctl_table { ctl_table devinet_proto_dir[2]; ctl_table devinet_root_dir[2]; } devinet_sysctl = { - devinet_vars: { + .devinet_vars = { { - ctl_name: NET_IPV4_CONF_FORWARDING, - procname: "forwarding", - data: &ipv4_devconf.forwarding, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &devinet_sysctl_forward, + .ctl_name = NET_IPV4_CONF_FORWARDING, + .procname = "forwarding", + .data = &ipv4_devconf.forwarding, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&devinet_sysctl_forward, }, { - ctl_name: NET_IPV4_CONF_MC_FORWARDING, - procname: "mc_forwarding", - data: &ipv4_devconf.mc_forwarding, - maxlen: sizeof(int), - mode: 0444, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_CONF_MC_FORWARDING, + .procname = "mc_forwarding", + .data = &ipv4_devconf.mc_forwarding, + .maxlen = sizeof(int), + .mode = 0444, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_CONF_ACCEPT_REDIRECTS, - procname: "accept_redirects", - data: &ipv4_devconf.accept_redirects, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_CONF_ACCEPT_REDIRECTS, + .procname = "accept_redirects", + .data = &ipv4_devconf.accept_redirects, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_CONF_SECURE_REDIRECTS, - procname: "secure_redirects", - data: &ipv4_devconf.secure_redirects, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_CONF_SECURE_REDIRECTS, + .procname = "secure_redirects", + .data = &ipv4_devconf.secure_redirects, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_CONF_SHARED_MEDIA, - procname: "shared_media", - data: &ipv4_devconf.shared_media, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_CONF_SHARED_MEDIA, + .procname = "shared_media", + .data = &ipv4_devconf.shared_media, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_CONF_RP_FILTER, - procname: "rp_filter", - data: &ipv4_devconf.rp_filter, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_CONF_RP_FILTER, + .procname = "rp_filter", + .data = &ipv4_devconf.rp_filter, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_CONF_SEND_REDIRECTS, - procname: "send_redirects", - data: &ipv4_devconf.send_redirects, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_CONF_SEND_REDIRECTS, + .procname = "send_redirects", + .data = &ipv4_devconf.send_redirects, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE, - procname: "accept_source_route", - data: &ipv4_devconf.accept_source_route, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE, + .procname = "accept_source_route", + .data = &ipv4_devconf.accept_source_route, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_CONF_PROXY_ARP, - procname: "proxy_arp", - data: &ipv4_devconf.proxy_arp, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_CONF_PROXY_ARP, + .procname = "proxy_arp", + .data = &ipv4_devconf.proxy_arp, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_CONF_MEDIUM_ID, - procname: "medium_id", - data: &ipv4_devconf.medium_id, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_CONF_MEDIUM_ID, + .procname = "medium_id", + .data = &ipv4_devconf.medium_id, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_CONF_BOOTP_RELAY, - procname: "bootp_relay", - data: &ipv4_devconf.bootp_relay, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_CONF_BOOTP_RELAY, + .procname = "bootp_relay", + .data = &ipv4_devconf.bootp_relay, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_CONF_LOG_MARTIANS, - procname: "log_martians", - data: &ipv4_devconf.log_martians, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_CONF_LOG_MARTIANS, + .procname = "log_martians", + .data = &ipv4_devconf.log_martians, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_CONF_TAG, - procname: "tag", - data: &ipv4_devconf.tag, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_CONF_TAG, + .procname = "tag", + .data = &ipv4_devconf.tag, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_CONF_ARPFILTER, - procname: "arp_filter", - data: &ipv4_devconf.arp_filter, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_CONF_ARPFILTER, + .procname = "arp_filter", + .data = &ipv4_devconf.arp_filter, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, }, - devinet_dev: { + .devinet_dev = { { - ctl_name: NET_PROTO_CONF_ALL, - procname: "all", - mode: 0555, - child: devinet_sysctl.devinet_vars, + .ctl_name = NET_PROTO_CONF_ALL, + .procname = "all", + .mode = 0555, + .child = devinet_sysctl.devinet_vars, }, }, - devinet_conf_dir: { + .devinet_conf_dir = { { - ctl_name: NET_IPV4_CONF, - procname: "conf", - mode: 0555, - child: devinet_sysctl.devinet_dev, + .ctl_name = NET_IPV4_CONF, + .procname = "conf", + .mode = 0555, + .child = devinet_sysctl.devinet_dev, }, }, - devinet_proto_dir: { + .devinet_proto_dir = { { - ctl_name: NET_IPV4, - procname: "ipv4", - mode: 0555, - child: devinet_sysctl.devinet_conf_dir, + .ctl_name = NET_IPV4, + .procname = "ipv4", + .mode = 0555, + .child = devinet_sysctl.devinet_conf_dir, }, }, - devinet_root_dir: { + .devinet_root_dir = { { - ctl_name: CTL_NET, - procname: "net", - mode: 0555, - child: devinet_sysctl.devinet_proto_dir, + .ctl_name = CTL_NET, + .procname = "net", + .mode = 0555, + .child = devinet_sysctl.devinet_proto_dir, }, }, }; diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 41b0750dcd21..c101889f0226 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -634,11 +634,11 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo } struct notifier_block fib_inetaddr_notifier = { - notifier_call: fib_inetaddr_event, + .notifier_call =fib_inetaddr_event, }; struct notifier_block fib_netdev_notifier = { - notifier_call: fib_netdev_event, + .notifier_call =fib_netdev_event, }; void __init ip_fib_init(void) diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c index 47230c8e451e..8ae6cbeee71e 100644 --- a/net/ipv4/fib_rules.c +++ b/net/ipv4/fib_rules.c @@ -77,25 +77,25 @@ struct fib_rule }; static struct fib_rule default_rule = { - r_clntref: ATOMIC_INIT(2), - r_preference: 0x7FFF, - r_table: RT_TABLE_DEFAULT, - r_action: RTN_UNICAST, + .r_clntref = ATOMIC_INIT(2), + .r_preference = 0x7FFF, + .r_table = RT_TABLE_DEFAULT, + .r_action = RTN_UNICAST, }; static struct fib_rule main_rule = { - r_next: &default_rule, - r_clntref: ATOMIC_INIT(2), - r_preference: 0x7FFE, - r_table: RT_TABLE_MAIN, - r_action: RTN_UNICAST, + .r_next = &default_rule, + .r_clntref = ATOMIC_INIT(2), + .r_preference = 0x7FFE, + .r_table = RT_TABLE_MAIN, + .r_action = RTN_UNICAST, }; static struct fib_rule local_rule = { - r_next: &main_rule, - r_clntref: ATOMIC_INIT(2), - r_table: RT_TABLE_LOCAL, - r_action: RTN_UNICAST, + .r_next = &main_rule, + .r_clntref = ATOMIC_INIT(2), + .r_table = RT_TABLE_LOCAL, + .r_action = RTN_UNICAST, }; static struct fib_rule *fib_rules = &local_rule; @@ -392,7 +392,7 @@ static int fib_rules_event(struct notifier_block *this, unsigned long event, voi struct notifier_block fib_rules_notifier = { - notifier_call: fib_rules_event, + .notifier_call =fib_rules_event, }; static __inline__ int inet_fill_rule(struct sk_buff *skb, diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index a1c6c5de3188..5cc69cd27013 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -121,68 +121,68 @@ struct icmp_mib icmp_statistics[NR_CPUS * 2]; struct icmp_err icmp_err_convert[] = { { - errno: ENETUNREACH, /* ICMP_NET_UNREACH */ - fatal: 0, + .errno =ENETUNREACH, /* ICMP_NET_UNREACH */ + .fatal =0, }, { - errno: EHOSTUNREACH, /* ICMP_HOST_UNREACH */ - fatal: 0, + .errno =EHOSTUNREACH, /* ICMP_HOST_UNREACH */ + .fatal =0, }, { - errno: ENOPROTOOPT /* ICMP_PROT_UNREACH */, - fatal: 1, + .errno =ENOPROTOOPT /* ICMP_PROT_UNREACH */, + .fatal =1, }, { - errno: ECONNREFUSED, /* ICMP_PORT_UNREACH */ - fatal: 1, + .errno =ECONNREFUSED, /* ICMP_PORT_UNREACH */ + .fatal =1, }, { - errno: EMSGSIZE, /* ICMP_FRAG_NEEDED */ - fatal: 0, + .errno =EMSGSIZE, /* ICMP_FRAG_NEEDED */ + .fatal =0, }, { - errno: EOPNOTSUPP, /* ICMP_SR_FAILED */ - fatal: 0, + .errno =EOPNOTSUPP, /* ICMP_SR_FAILED */ + .fatal =0, }, { - errno: ENETUNREACH, /* ICMP_NET_UNKNOWN */ - fatal: 1, + .errno =ENETUNREACH, /* ICMP_NET_UNKNOWN */ + .fatal =1, }, { - errno: EHOSTDOWN, /* ICMP_HOST_UNKNOWN */ - fatal: 1, + .errno =EHOSTDOWN, /* ICMP_HOST_UNKNOWN */ + .fatal =1, }, { - errno: ENONET, /* ICMP_HOST_ISOLATED */ - fatal: 1, + .errno =ENONET, /* ICMP_HOST_ISOLATED */ + .fatal =1, }, { - errno: ENETUNREACH, /* ICMP_NET_ANO */ - fatal: 1, + .errno =ENETUNREACH, /* ICMP_NET_ANO */ + .fatal =1, }, { - errno: EHOSTUNREACH, /* ICMP_HOST_ANO */ - fatal: 1, + .errno =EHOSTUNREACH, /* ICMP_HOST_ANO */ + .fatal =1, }, { - errno: ENETUNREACH, /* ICMP_NET_UNR_TOS */ - fatal: 0, + .errno =ENETUNREACH, /* ICMP_NET_UNR_TOS */ + .fatal =0, }, { - errno: EHOSTUNREACH, /* ICMP_HOST_UNR_TOS */ - fatal: 0, + .errno =EHOSTUNREACH, /* ICMP_HOST_UNR_TOS */ + .fatal =0, }, { - errno: EHOSTUNREACH, /* ICMP_PKT_FILTERED */ - fatal: 1, + .errno =EHOSTUNREACH, /* ICMP_PKT_FILTERED */ + .fatal =1, }, { - errno: EHOSTUNREACH, /* ICMP_PREC_VIOLATION */ - fatal: 1, + .errno =EHOSTUNREACH, /* ICMP_PREC_VIOLATION */ + .fatal =1, }, { - errno: EHOSTUNREACH, /* ICMP_PREC_CUTOFF */ - fatal: 1, + .errno =EHOSTUNREACH, /* ICMP_PREC_CUTOFF */ + .fatal =1, }, }; @@ -1022,123 +1022,123 @@ error: static struct icmp_control icmp_pointers[NR_ICMP_TYPES + 1] = { /* ECHO REPLY (0) */ [0] = { - output: &icmp_statistics[0].IcmpOutEchoReps, - input: &icmp_statistics[0].IcmpInEchoReps, - handler: icmp_discard, + .output = &icmp_statistics[0].IcmpOutEchoReps, + .input = &icmp_statistics[0].IcmpInEchoReps, + .handler = icmp_discard, }, [1] = { - output: &icmp_statistics[0].dummy, - input: &icmp_statistics[0].IcmpInErrors, - handler: icmp_discard, - error: 1, + .output = &icmp_statistics[0].dummy, + .input = &icmp_statistics[0].IcmpInErrors, + .handler = icmp_discard, + .error = 1, }, [2] = { - output: &icmp_statistics[0].dummy, - input: &icmp_statistics[0].IcmpInErrors, - handler: icmp_discard, - error: 1, + .output = &icmp_statistics[0].dummy, + .input = &icmp_statistics[0].IcmpInErrors, + .handler = icmp_discard, + .error = 1, }, /* DEST UNREACH (3) */ [3] = { - output: &icmp_statistics[0].IcmpOutDestUnreachs, - input: &icmp_statistics[0].IcmpInDestUnreachs, - handler: icmp_unreach, - error: 1, + .output = &icmp_statistics[0].IcmpOutDestUnreachs, + .input = &icmp_statistics[0].IcmpInDestUnreachs, + .handler = icmp_unreach, + .error = 1, }, /* SOURCE QUENCH (4) */ [4] = { - output: &icmp_statistics[0].IcmpOutSrcQuenchs, - input: &icmp_statistics[0].IcmpInSrcQuenchs, + .output = &icmp_statistics[0].IcmpOutSrcQuenchs, + .input = &icmp_statistics[0].IcmpInSrcQuenchs, icmp_unreach, - error: 1, + .error = 1, }, /* REDIRECT (5) */ [5] = { - output: &icmp_statistics[0].IcmpOutRedirects, - input: &icmp_statistics[0].IcmpInRedirects, - handler: icmp_redirect, - error: 1, + .output = &icmp_statistics[0].IcmpOutRedirects, + .input = &icmp_statistics[0].IcmpInRedirects, + .handler = icmp_redirect, + .error = 1, }, [6] = { - output: &icmp_statistics[0].dummy, - input: &icmp_statistics[0].IcmpInErrors, - handler: icmp_discard, - error: 1, + .output = &icmp_statistics[0].dummy, + .input = &icmp_statistics[0].IcmpInErrors, + .handler = icmp_discard, + .error = 1, }, [7] = { - output: &icmp_statistics[0].dummy, - input: &icmp_statistics[0].IcmpInErrors, - handler: icmp_discard, - error: 1, + .output = &icmp_statistics[0].dummy, + .input = &icmp_statistics[0].IcmpInErrors, + .handler = icmp_discard, + .error = 1, }, /* ECHO (8) */ [8] = { - output: &icmp_statistics[0].IcmpOutEchos, - input: &icmp_statistics[0].IcmpInEchos, - handler: icmp_echo, - error: 0, + .output = &icmp_statistics[0].IcmpOutEchos, + .input = &icmp_statistics[0].IcmpInEchos, + .handler = icmp_echo, + .error = 0, }, [9] = { - output: &icmp_statistics[0].dummy, - input: &icmp_statistics[0].IcmpInErrors, - handler: icmp_discard, - error: 1, + .output = &icmp_statistics[0].dummy, + .input = &icmp_statistics[0].IcmpInErrors, + .handler = icmp_discard, + .error = 1, }, [10] = { - output: &icmp_statistics[0].dummy, - input: &icmp_statistics[0].IcmpInErrors, - handler: icmp_discard, - error: 1, + .output = &icmp_statistics[0].dummy, + .input = &icmp_statistics[0].IcmpInErrors, + .handler = icmp_discard, + .error = 1, }, /* TIME EXCEEDED (11) */ [11] = { - output: &icmp_statistics[0].IcmpOutTimeExcds, - input: &icmp_statistics[0].IcmpInTimeExcds, - handler: icmp_unreach, - error: 1, + .output = &icmp_statistics[0].IcmpOutTimeExcds, + .input = &icmp_statistics[0].IcmpInTimeExcds, + .handler = icmp_unreach, + .error = 1, }, /* PARAMETER PROBLEM (12) */ [12] = { - output: &icmp_statistics[0].IcmpOutParmProbs, - input: &icmp_statistics[0].IcmpInParmProbs, - handler: icmp_unreach, - error: 1, + .output = &icmp_statistics[0].IcmpOutParmProbs, + .input = &icmp_statistics[0].IcmpInParmProbs, + .handler = icmp_unreach, + .error = 1, }, /* TIMESTAMP (13) */ [13] = { - output: &icmp_statistics[0].IcmpOutTimestamps, - input: &icmp_statistics[0].IcmpInTimestamps, - handler: icmp_timestamp, + .output = &icmp_statistics[0].IcmpOutTimestamps, + .input = &icmp_statistics[0].IcmpInTimestamps, + .handler = icmp_timestamp, }, /* TIMESTAMP REPLY (14) */ [14] = { - output: &icmp_statistics[0].IcmpOutTimestampReps, - input: &icmp_statistics[0].IcmpInTimestampReps, - handler: icmp_discard, + .output = &icmp_statistics[0].IcmpOutTimestampReps, + .input = &icmp_statistics[0].IcmpInTimestampReps, + .handler = icmp_discard, }, /* INFO (15) */ [15] = { - output: &icmp_statistics[0].dummy, - input: &icmp_statistics[0].dummy, - handler: icmp_discard, + .output = &icmp_statistics[0].dummy, + .input = &icmp_statistics[0].dummy, + .handler = icmp_discard, }, /* INFO REPLY (16) */ [16] = { - output: &icmp_statistics[0].dummy, - input: &icmp_statistics[0].dummy, - handler: icmp_discard, + .output = &icmp_statistics[0].dummy, + .input = &icmp_statistics[0].dummy, + .handler = icmp_discard, }, /* ADDR MASK (17) */ [17] = { - output: &icmp_statistics[0].IcmpOutAddrMasks, - input: &icmp_statistics[0].IcmpInAddrMasks, - handler: icmp_address, + .output = &icmp_statistics[0].IcmpOutAddrMasks, + .input = &icmp_statistics[0].IcmpInAddrMasks, + .handler = icmp_address, }, /* ADDR MASK REPLY (18) */ [18] = { - output: &icmp_statistics[0].IcmpOutAddrMaskReps, - input: &icmp_statistics[0].IcmpInAddrMaskReps, - handler: icmp_address_reply, + .output = &icmp_statistics[0].IcmpOutAddrMaskReps, + .input = &icmp_statistics[0].IcmpInAddrMaskReps, + .handler = icmp_address_reply, } }; diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index cf5c0b253cdb..48d1064ffabe 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -120,13 +120,13 @@ static int ipgre_tunnel_init(struct net_device *dev); static int ipgre_fb_tunnel_init(struct net_device *dev); static struct net_device ipgre_fb_tunnel_dev = { - name: "gre0", - init: ipgre_fb_tunnel_init + .name = "gre0", + .init = ipgre_fb_tunnel_init }; static struct ip_tunnel ipgre_fb_tunnel = { - dev: &ipgre_fb_tunnel_dev, - parms: { name: "gre0" } + .dev = &ipgre_fb_tunnel_dev, + .parms ={ name: "gre0" } }; /* Tunnel hash table */ diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 4ee3ed1be090..2d128cd3947a 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -382,8 +382,8 @@ static int __init ic_defaults(void) static int ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt); static struct packet_type rarp_packet_type __initdata = { - type: __constant_htons(ETH_P_RARP), - func: ic_rarp_recv, + .type = __constant_htons(ETH_P_RARP), + .func = ic_rarp_recv, }; static inline void ic_rarp_init(void) @@ -522,8 +522,8 @@ struct bootp_pkt { /* BOOTP packet format */ static int ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt); static struct packet_type bootp_packet_type __initdata = { - type: __constant_htons(ETH_P_IP), - func: ic_bootp_recv, + .type = __constant_htons(ETH_P_IP), + .func = ic_bootp_recv, }; diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index 82634df7c6fe..a8fa8e86e673 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c @@ -123,13 +123,13 @@ static int ipip_fb_tunnel_init(struct net_device *dev); static int ipip_tunnel_init(struct net_device *dev); static struct net_device ipip_fb_tunnel_dev = { - name: "tunl0", - init: ipip_fb_tunnel_init, + .name = "tunl0", + .init = ipip_fb_tunnel_init, }; static struct ip_tunnel ipip_fb_tunnel = { - dev: &ipip_fb_tunnel_dev, - parms: { name: "tunl0", } + .dev = &ipip_fb_tunnel_dev, + .parms ={ name: "tunl0", } }; static struct ip_tunnel *tunnels_r_l[HASH_SIZE]; @@ -877,10 +877,10 @@ int __init ipip_fb_tunnel_init(struct net_device *dev) } static struct inet_protocol ipip_protocol = { - handler: ipip_rcv, - err_handler: ipip_err, - protocol: IPPROTO_IPIP, - name: "IPIP" + .handler = ipip_rcv, + .err_handler = ipip_err, + .protocol = IPPROTO_IPIP, + .name = "IPIP" }; static char banner[] __initdata = diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c index e9932533f87a..080c3d1efdd4 100644 --- a/net/ipv4/netfilter/ip_queue.c +++ b/net/ipv4/netfilter/ip_queue.c @@ -2,13 +2,14 @@ * This is a module which is used for queueing IPv4 packets and * communicating with userspace via netlink. * - * (C) 2000 James Morris, this code is GPL. + * (C) 2000-2002 James Morris, this code is GPL. * * 2000-03-27: Simplified code (thanks to Andi Kleen for clues). * 2000-05-20: Fixed notifier problems (following Miguel Freitas' report). * 2000-06-19: Fixed so nfmark is copied to metadata (reported by Sebastian * Zander). * 2000-08-01: Added Nick Williams' MAC support. + * 2002-06-25: Code cleanup. * */ #include <linux/module.h> @@ -18,205 +19,310 @@ #include <linux/notifier.h> #include <linux/netdevice.h> #include <linux/netfilter.h> +#include <linux/netfilter_ipv4/ip_queue.h> +#include <linux/netfilter_ipv4/ip_tables.h> #include <linux/netlink.h> #include <linux/spinlock.h> -#include <linux/rtnetlink.h> +#include <linux/brlock.h> #include <linux/sysctl.h> #include <linux/proc_fs.h> #include <net/sock.h> #include <net/route.h> -#include <linux/netfilter_ipv4/ip_queue.h> -#include <linux/netfilter_ipv4/ip_tables.h> - #define IPQ_QMAX_DEFAULT 1024 #define IPQ_PROC_FS_NAME "ip_queue" #define NET_IPQ_QMAX 2088 #define NET_IPQ_QMAX_NAME "ip_queue_maxlen" -typedef struct ipq_rt_info { +struct ipq_rt_info { __u8 tos; __u32 daddr; __u32 saddr; -} ipq_rt_info_t; - -typedef struct ipq_queue_element { - struct list_head list; /* Links element into queue */ - int verdict; /* Current verdict */ - struct nf_info *info; /* Extra info from netfilter */ - struct sk_buff *skb; /* Packet inside */ - ipq_rt_info_t rt_info; /* May need post-mangle routing */ -} ipq_queue_element_t; - -typedef int (*ipq_send_cb_t)(ipq_queue_element_t *e); - -typedef struct ipq_peer { - pid_t pid; /* PID of userland peer */ - unsigned char died; /* We think the peer died */ - unsigned char copy_mode; /* Copy packet as well as metadata? */ - size_t copy_range; /* Range past metadata to copy */ - ipq_send_cb_t send; /* Callback for sending data to peer */ -} ipq_peer_t; - -typedef struct ipq_queue { - int len; /* Current queue len */ - int *maxlen; /* Maximum queue len, via sysctl */ - unsigned char flushing; /* If queue is being flushed */ - unsigned char terminate; /* If the queue is being terminated */ - struct list_head list; /* Head of packet queue */ - spinlock_t lock; /* Queue spinlock */ - ipq_peer_t peer; /* Userland peer */ -} ipq_queue_t; - -/**************************************************************************** - * - * Packet queue - * - ****************************************************************************/ -/* Dequeue a packet if matched by cmp, or the next available if cmp is NULL */ -static ipq_queue_element_t * -ipq_dequeue(ipq_queue_t *q, - int (*cmp)(ipq_queue_element_t *, unsigned long), - unsigned long data) +}; + +struct ipq_queue_entry { + struct list_head list; + struct nf_info *info; + struct sk_buff *skb; + struct ipq_rt_info rt_info; +}; + +typedef int (*ipq_cmpfn)(struct ipq_queue_entry *, unsigned long); + +static unsigned char copy_mode = IPQ_COPY_NONE; +static unsigned int queue_maxlen = IPQ_QMAX_DEFAULT; +static rwlock_t queue_lock = RW_LOCK_UNLOCKED; +static int peer_pid; +static unsigned int copy_range; +static unsigned int queue_total; +static struct sock *ipqnl; +static LIST_HEAD(queue_list); +static DECLARE_MUTEX(ipqnl_sem); + +static void +ipq_issue_verdict(struct ipq_queue_entry *entry, int verdict) { - struct list_head *i; + nf_reinject(entry->skb, entry->info, verdict); + kfree(entry); +} - spin_lock_bh(&q->lock); - for (i = q->list.prev; i != &q->list; i = i->prev) { - ipq_queue_element_t *e = (ipq_queue_element_t *)i; +static inline int +__ipq_enqueue_entry(struct ipq_queue_entry *entry) +{ + if (queue_total >= queue_maxlen) { + if (net_ratelimit()) + printk(KERN_WARNING "ip_queue: full at %d entries, " + "dropping packet(s).\n", queue_total); + return -ENOSPC; + } + list_add(&entry->list, &queue_list); + queue_total++; + return 0; +} + +/* + * Find and return a queued entry matched by cmpfn, or return the last + * entry if cmpfn is NULL. + */ +static inline struct ipq_queue_entry * +__ipq_find_entry(ipq_cmpfn cmpfn, unsigned long data) +{ + struct list_head *p; + + list_for_each_prev(p, &queue_list) { + struct ipq_queue_entry *entry = (struct ipq_queue_entry *)p; - if (!cmp || cmp(e, data)) { - list_del(&e->list); - q->len--; - spin_unlock_bh(&q->lock); - return e; - } + if (!cmpfn || cmpfn(entry, data)) + return entry; } - spin_unlock_bh(&q->lock); return NULL; } -/* Flush all packets */ -static void ipq_flush(ipq_queue_t *q) +static inline void +__ipq_dequeue_entry(struct ipq_queue_entry *entry) +{ + list_del(&entry->list); + queue_total--; +} + +static inline struct ipq_queue_entry * +__ipq_find_dequeue_entry(ipq_cmpfn cmpfn, unsigned long data) +{ + struct ipq_queue_entry *entry; + + entry = __ipq_find_entry(cmpfn, data); + if (entry == NULL) + return NULL; + + __ipq_dequeue_entry(entry); + return entry; +} + + +static inline void +__ipq_flush(int verdict) { - ipq_queue_element_t *e; + struct ipq_queue_entry *entry; - spin_lock_bh(&q->lock); - q->flushing = 1; - spin_unlock_bh(&q->lock); - while ((e = ipq_dequeue(q, NULL, 0))) { - e->verdict = NF_DROP; - nf_reinject(e->skb, e->info, e->verdict); - kfree(e); + while ((entry = __ipq_find_dequeue_entry(NULL, 0))) + ipq_issue_verdict(entry, verdict); +} + +static inline int +__ipq_set_mode(unsigned char mode, unsigned int range) +{ + int status = 0; + + switch(mode) { + case IPQ_COPY_NONE: + case IPQ_COPY_META: + copy_mode = mode; + copy_range = 0; + break; + + case IPQ_COPY_PACKET: + copy_mode = mode; + copy_range = range; + if (copy_range > 0xFFFF) + copy_range = 0xFFFF; + break; + + default: + status = -EINVAL; + } - spin_lock_bh(&q->lock); - q->flushing = 0; - spin_unlock_bh(&q->lock); + return status; } -static ipq_queue_t *ipq_create_queue(nf_queue_outfn_t outfn, - ipq_send_cb_t send_cb, - int *errp, int *sysctl_qmax) +static inline void +__ipq_reset(void) { - int status; - ipq_queue_t *q; + peer_pid = 0; + __ipq_set_mode(IPQ_COPY_NONE, 0); + __ipq_flush(NF_DROP); +} + +static struct ipq_queue_entry * +ipq_find_dequeue_entry(ipq_cmpfn cmpfn, unsigned long data) +{ + struct ipq_queue_entry *entry; + + write_lock_bh(&queue_lock); + entry = __ipq_find_dequeue_entry(cmpfn, data); + write_unlock_bh(&queue_lock); + return entry; +} + +static void +ipq_flush(int verdict) +{ + write_lock_bh(&queue_lock); + __ipq_flush(verdict); + write_unlock_bh(&queue_lock); +} + +static struct sk_buff * +ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp) +{ + unsigned char *old_tail; + size_t size = 0; + size_t data_len = 0; + struct sk_buff *skb; + struct ipq_packet_msg *pmsg; + struct nlmsghdr *nlh; - *errp = 0; - q = kmalloc(sizeof(ipq_queue_t), GFP_KERNEL); - if (q == NULL) { - *errp = -ENOMEM; + read_lock_bh(&queue_lock); + + switch (copy_mode) { + case IPQ_COPY_META: + case IPQ_COPY_NONE: + size = NLMSG_SPACE(sizeof(*pmsg)); + data_len = 0; + break; + + case IPQ_COPY_PACKET: + if (copy_range == 0 || copy_range > entry->skb->len) + data_len = entry->skb->len; + else + data_len = copy_range; + + size = NLMSG_SPACE(sizeof(*pmsg) + data_len); + break; + + default: + *errp = -EINVAL; + read_unlock_bh(&queue_lock); return NULL; } - q->peer.pid = 0; - q->peer.died = 0; - q->peer.copy_mode = IPQ_COPY_NONE; - q->peer.copy_range = 0; - q->peer.send = send_cb; - q->len = 0; - q->maxlen = sysctl_qmax; - q->flushing = 0; - q->terminate = 0; - INIT_LIST_HEAD(&q->list); - spin_lock_init(&q->lock); - status = nf_register_queue_handler(PF_INET, outfn, q); - if (status < 0) { - *errp = -EBUSY; - kfree(q); - return NULL; + + read_unlock_bh(&queue_lock); + + skb = alloc_skb(size, GFP_ATOMIC); + if (!skb) + goto nlmsg_failure; + + old_tail= skb->tail; + nlh = NLMSG_PUT(skb, 0, 0, IPQM_PACKET, size - sizeof(*nlh)); + pmsg = NLMSG_DATA(nlh); + memset(pmsg, 0, sizeof(*pmsg)); + + pmsg->packet_id = (unsigned long )entry; + pmsg->data_len = data_len; + pmsg->timestamp_sec = entry->skb->stamp.tv_sec; + pmsg->timestamp_usec = entry->skb->stamp.tv_usec; + pmsg->mark = entry->skb->nfmark; + pmsg->hook = entry->info->hook; + pmsg->hw_protocol = entry->skb->protocol; + + if (entry->info->indev) + strcpy(pmsg->indev_name, entry->info->indev->name); + else + pmsg->indev_name[0] = '\0'; + + if (entry->info->outdev) + strcpy(pmsg->outdev_name, entry->info->outdev->name); + else + pmsg->outdev_name[0] = '\0'; + + if (entry->info->indev && entry->skb->dev) { + pmsg->hw_type = entry->skb->dev->type; + if (entry->skb->dev->hard_header_parse) + pmsg->hw_addrlen = + entry->skb->dev->hard_header_parse(entry->skb, + pmsg->hw_addr); } - return q; + + if (data_len) + memcpy(pmsg->payload, entry->skb->data, data_len); + + nlh->nlmsg_len = skb->tail - old_tail; + return skb; + +nlmsg_failure: + if (skb) + kfree_skb(skb); + *errp = -EINVAL; + printk(KERN_ERR "ip_queue: error creating packet message\n"); + return NULL; } -static int ipq_enqueue(ipq_queue_t *q, - struct sk_buff *skb, struct nf_info *info) +static int +ipq_enqueue_packet(struct sk_buff *skb, struct nf_info *info, void *data) { - ipq_queue_element_t *e; - int status; - - e = kmalloc(sizeof(*e), GFP_ATOMIC); - if (e == NULL) { - printk(KERN_ERR "ip_queue: OOM in enqueue\n"); + int status = -EINVAL; + struct sk_buff *nskb; + struct ipq_queue_entry *entry; + + if (copy_mode == IPQ_COPY_NONE) + return -EAGAIN; + + entry = kmalloc(sizeof(*entry), GFP_ATOMIC); + if (entry == NULL) { + printk(KERN_ERR "ip_queue: OOM in ipq_enqueue_packet()\n"); return -ENOMEM; } - e->verdict = NF_DROP; - e->info = info; - e->skb = skb; + entry->info = info; + entry->skb = skb; - if (e->info->hook == NF_IP_LOCAL_OUT) { + if (entry->info->hook == NF_IP_LOCAL_OUT) { struct iphdr *iph = skb->nh.iph; - e->rt_info.tos = iph->tos; - e->rt_info.daddr = iph->daddr; - e->rt_info.saddr = iph->saddr; + entry->rt_info.tos = iph->tos; + entry->rt_info.daddr = iph->daddr; + entry->rt_info.saddr = iph->saddr; } - spin_lock_bh(&q->lock); - if (q->len >= *q->maxlen) { - spin_unlock_bh(&q->lock); - if (net_ratelimit()) - printk(KERN_WARNING "ip_queue: full at %d entries, " - "dropping packet(s).\n", q->len); - goto free_drop; - } - if (q->flushing || q->peer.copy_mode == IPQ_COPY_NONE - || q->peer.pid == 0 || q->peer.died || q->terminate) { - spin_unlock_bh(&q->lock); - goto free_drop; - } - status = q->peer.send(e); - if (status > 0) { - list_add(&e->list, &q->list); - q->len++; - spin_unlock_bh(&q->lock); - return status; - } - spin_unlock_bh(&q->lock); - if (status == -ECONNREFUSED) { - printk(KERN_INFO "ip_queue: peer %d died, " - "resetting state and flushing queue\n", q->peer.pid); - q->peer.died = 1; - q->peer.pid = 0; - q->peer.copy_mode = IPQ_COPY_NONE; - q->peer.copy_range = 0; - ipq_flush(q); - } -free_drop: - kfree(e); - return -EBUSY; -} + nskb = ipq_build_packet_message(entry, &status); + if (nskb == NULL) + goto err_out_free; + + write_lock_bh(&queue_lock); + + if (!peer_pid) + goto err_out_unlock; -static void ipq_destroy_queue(ipq_queue_t *q) -{ - nf_unregister_queue_handler(PF_INET); - spin_lock_bh(&q->lock); - q->terminate = 1; - spin_unlock_bh(&q->lock); - ipq_flush(q); - kfree(q); + status = netlink_unicast(ipqnl, nskb, peer_pid, MSG_DONTWAIT); + if (status < 0) + goto err_out_unlock; + + status = __ipq_enqueue_entry(entry); + if (status < 0) + goto err_out_unlock; + + write_unlock_bh(&queue_lock); + return status; + +err_out_unlock: + write_unlock_bh(&queue_lock); + +err_out_free: + kfree(entry); + return status; } -static int ipq_mangle_ipv4(ipq_verdict_msg_t *v, ipq_queue_element_t *e) +static int +ipq_mangle_ipv4(ipq_verdict_msg_t *v, struct ipq_queue_entry *e) { int diff; struct iphdr *user_iph = (struct iphdr *)v->payload; @@ -266,296 +372,216 @@ static int ipq_mangle_ipv4(ipq_verdict_msg_t *v, ipq_queue_element_t *e) return 0; } -static inline int id_cmp(ipq_queue_element_t *e, unsigned long id) +static inline int +id_cmp(struct ipq_queue_entry *e, unsigned long id) { return (id == (unsigned long )e); } -static int ipq_set_verdict(ipq_queue_t *q, - ipq_verdict_msg_t *v, unsigned int len) +static int +ipq_set_verdict(struct ipq_verdict_msg *vmsg, unsigned int len) { - ipq_queue_element_t *e; + struct ipq_queue_entry *entry; - if (v->value > NF_MAX_VERDICT) + if (vmsg->value > NF_MAX_VERDICT) return -EINVAL; - e = ipq_dequeue(q, id_cmp, v->id); - if (e == NULL) + + entry = ipq_find_dequeue_entry(id_cmp, vmsg->id); + if (entry == NULL) return -ENOENT; else { - e->verdict = v->value; - if (v->data_len && v->data_len == len) - if (ipq_mangle_ipv4(v, e) < 0) - e->verdict = NF_DROP; - nf_reinject(e->skb, e->info, e->verdict); - kfree(e); + int verdict = vmsg->value; + + if (vmsg->data_len && vmsg->data_len == len) + if (ipq_mangle_ipv4(vmsg, entry) < 0) + verdict = NF_DROP; + + ipq_issue_verdict(entry, verdict); return 0; } } -static int ipq_receive_peer(ipq_queue_t *q, ipq_peer_msg_t *m, - unsigned char type, unsigned int len) +static int +ipq_set_mode(unsigned char mode, unsigned int range) { + int status; + + write_lock_bh(&queue_lock); + status = __ipq_set_mode(mode, range); + write_unlock_bh(&queue_lock); + return status; +} +static int +ipq_receive_peer(struct ipq_peer_msg *pmsg, + unsigned char type, unsigned int len) +{ int status = 0; - int busy; - - spin_lock_bh(&q->lock); - busy = (q->terminate || q->flushing); - spin_unlock_bh(&q->lock); - if (busy) - return -EBUSY; - if (len < sizeof(ipq_peer_msg_t)) + + if (len < sizeof(*pmsg)) return -EINVAL; + switch (type) { - case IPQM_MODE: - switch (m->msg.mode.value) { - case IPQ_COPY_META: - q->peer.copy_mode = IPQ_COPY_META; - q->peer.copy_range = 0; - break; - case IPQ_COPY_PACKET: - q->peer.copy_mode = IPQ_COPY_PACKET; - q->peer.copy_range = m->msg.mode.range; - if (q->peer.copy_range > 0xFFFF) - q->peer.copy_range = 0xFFFF; - break; - default: - status = -EINVAL; - } - break; - case IPQM_VERDICT: - if (m->msg.verdict.value > NF_MAX_VERDICT) - status = -EINVAL; - else - status = ipq_set_verdict(q, - &m->msg.verdict, - len - sizeof(*m)); + case IPQM_MODE: + status = ipq_set_mode(pmsg->msg.mode.value, + pmsg->msg.mode.range); + break; + + case IPQM_VERDICT: + if (pmsg->msg.verdict.value > NF_MAX_VERDICT) + status = -EINVAL; + else + status = ipq_set_verdict(&pmsg->msg.verdict, + len - sizeof(*pmsg)); break; - default: - status = -EINVAL; + default: + status = -EINVAL; } return status; } -static inline int dev_cmp(ipq_queue_element_t *e, unsigned long ifindex) +static int +dev_cmp(struct ipq_queue_entry *entry, unsigned long ifindex) { - if (e->info->indev) - if (e->info->indev->ifindex == ifindex) + if (entry->info->indev) + if (entry->info->indev->ifindex == ifindex) return 1; - if (e->info->outdev) - if (e->info->outdev->ifindex == ifindex) + + if (entry->info->outdev) + if (entry->info->outdev->ifindex == ifindex) return 1; + return 0; } -/* Drop any queued packets associated with device ifindex */ -static void ipq_dev_drop(ipq_queue_t *q, int ifindex) +static void +ipq_dev_drop(int ifindex) { - ipq_queue_element_t *e; + struct ipq_queue_entry *entry; - while ((e = ipq_dequeue(q, dev_cmp, ifindex))) { - e->verdict = NF_DROP; - nf_reinject(e->skb, e->info, e->verdict); - kfree(e); - } -} - -/**************************************************************************** - * - * Netfilter interface - * - ****************************************************************************/ - -/* - * Packets arrive here from netfilter for queuing to userspace. - * All of them must be fed back via nf_reinject() or Alexey will kill Rusty. - */ -static int netfilter_receive(struct sk_buff *skb, - struct nf_info *info, void *data) -{ - return ipq_enqueue((ipq_queue_t *)data, skb, info); -} - -/**************************************************************************** - * - * Netlink interface. - * - ****************************************************************************/ - -static struct sock *nfnl = NULL; -ipq_queue_t *nlq = NULL; - -static struct sk_buff *netlink_build_message(ipq_queue_element_t *e, int *errp) -{ - unsigned char *old_tail; - size_t size = 0; - size_t data_len = 0; - struct sk_buff *skb; - ipq_packet_msg_t *pm; - struct nlmsghdr *nlh; - - switch (nlq->peer.copy_mode) { - size_t copy_range; - - case IPQ_COPY_META: - size = NLMSG_SPACE(sizeof(*pm)); - data_len = 0; - break; - case IPQ_COPY_PACKET: - copy_range = nlq->peer.copy_range; - if (copy_range == 0 || copy_range > e->skb->len) - data_len = e->skb->len; - else - data_len = copy_range; - size = NLMSG_SPACE(sizeof(*pm) + data_len); - - break; - case IPQ_COPY_NONE: - default: - *errp = -EINVAL; - return NULL; - } - skb = alloc_skb(size, GFP_ATOMIC); - if (!skb) - goto nlmsg_failure; - old_tail = skb->tail; - nlh = NLMSG_PUT(skb, 0, 0, IPQM_PACKET, size - sizeof(*nlh)); - pm = NLMSG_DATA(nlh); - memset(pm, 0, sizeof(*pm)); - pm->packet_id = (unsigned long )e; - pm->data_len = data_len; - pm->timestamp_sec = e->skb->stamp.tv_sec; - pm->timestamp_usec = e->skb->stamp.tv_usec; - pm->mark = e->skb->nfmark; - pm->hook = e->info->hook; - if (e->info->indev) strcpy(pm->indev_name, e->info->indev->name); - else pm->indev_name[0] = '\0'; - if (e->info->outdev) strcpy(pm->outdev_name, e->info->outdev->name); - else pm->outdev_name[0] = '\0'; - pm->hw_protocol = e->skb->protocol; - if (e->info->indev && e->skb->dev) { - pm->hw_type = e->skb->dev->type; - if (e->skb->dev->hard_header_parse) - pm->hw_addrlen = - e->skb->dev->hard_header_parse(e->skb, - pm->hw_addr); - } - if (data_len) - memcpy(pm->payload, e->skb->data, data_len); - nlh->nlmsg_len = skb->tail - old_tail; - NETLINK_CB(skb).dst_groups = 0; - return skb; -nlmsg_failure: - if (skb) - kfree_skb(skb); - *errp = 0; - printk(KERN_ERR "ip_queue: error creating netlink message\n"); - return NULL; -} - -static int netlink_send_peer(ipq_queue_element_t *e) -{ - int status = 0; - struct sk_buff *skb; - - skb = netlink_build_message(e, &status); - if (skb == NULL) - return status; - return netlink_unicast(nfnl, skb, nlq->peer.pid, MSG_DONTWAIT); + while ((entry = ipq_find_dequeue_entry(dev_cmp, ifindex)) != NULL) + ipq_issue_verdict(entry, NF_DROP); } #define RCV_SKB_FAIL(err) do { netlink_ack(skb, nlh, (err)); return; } while (0) -static __inline__ void netlink_receive_user_skb(struct sk_buff *skb) +static inline void +ipq_rcv_skb(struct sk_buff *skb) { - int status, type; + int status, type, pid, flags, nlmsglen, skblen; struct nlmsghdr *nlh; - if (skb->len < sizeof(struct nlmsghdr)) + skblen = skb->len; + if (skblen < sizeof(*nlh)) return; nlh = (struct nlmsghdr *)skb->data; - if (nlh->nlmsg_len < sizeof(struct nlmsghdr) - || skb->len < nlh->nlmsg_len) - return; + nlmsglen = nlh->nlmsg_len; + if (nlmsglen < sizeof(*nlh) || skblen < nlmsglen) + return; - if(nlh->nlmsg_pid <= 0 - || !(nlh->nlmsg_flags & NLM_F_REQUEST) - || nlh->nlmsg_flags & NLM_F_MULTI) + pid = nlh->nlmsg_pid; + flags = nlh->nlmsg_flags; + + if(pid <= 0 || !(flags & NLM_F_REQUEST) || flags & NLM_F_MULTI) RCV_SKB_FAIL(-EINVAL); - if (nlh->nlmsg_flags & MSG_TRUNC) + + if (flags & MSG_TRUNC) RCV_SKB_FAIL(-ECOMM); + type = nlh->nlmsg_type; if (type < NLMSG_NOOP || type >= IPQM_MAX) RCV_SKB_FAIL(-EINVAL); + if (type <= IPQM_BASE) return; + if(!cap_raised(NETLINK_CB(skb).eff_cap, CAP_NET_ADMIN)) RCV_SKB_FAIL(-EPERM); - if (nlq->peer.pid && !nlq->peer.died - && (nlq->peer.pid != nlh->nlmsg_pid)) { - printk(KERN_WARNING "ip_queue: peer pid changed from %d to " - "%d, flushing queue\n", nlq->peer.pid, nlh->nlmsg_pid); - ipq_flush(nlq); - } - nlq->peer.pid = nlh->nlmsg_pid; - nlq->peer.died = 0; - status = ipq_receive_peer(nlq, NLMSG_DATA(nlh), - type, skb->len - NLMSG_LENGTH(0)); + + write_lock_bh(&queue_lock); + + if (peer_pid) { + if (peer_pid != pid) { + write_unlock_bh(&queue_lock); + RCV_SKB_FAIL(-EBUSY); + } + } + else + peer_pid = pid; + + write_unlock_bh(&queue_lock); + + status = ipq_receive_peer(NLMSG_DATA(nlh), type, + skblen - NLMSG_LENGTH(0)); if (status < 0) RCV_SKB_FAIL(status); - if (nlh->nlmsg_flags & NLM_F_ACK) + + if (flags & NLM_F_ACK) netlink_ack(skb, nlh, 0); return; } -/* Note: we are only dealing with single part messages at the moment. */ -static void netlink_receive_user_sk(struct sock *sk, int len) +static void +ipq_rcv_sk(struct sock *sk, int len) { do { struct sk_buff *skb; - if (rtnl_shlock_nowait()) + if (down_trylock(&ipqnl_sem)) return; + while ((skb = skb_dequeue(&sk->receive_queue)) != NULL) { - netlink_receive_user_skb(skb); + ipq_rcv_skb(skb); kfree_skb(skb); } - up(&rtnl_sem); - } while (nfnl && nfnl->receive_queue.qlen); -} + + up(&ipqnl_sem); -/**************************************************************************** - * - * System events - * - ****************************************************************************/ + } while (ipqnl && ipqnl->receive_queue.qlen); +} -static int receive_event(struct notifier_block *this, - unsigned long event, void *ptr) +static int +ipq_rcv_dev_event(struct notifier_block *this, + unsigned long event, void *ptr) { struct net_device *dev = ptr; /* Drop any packets associated with the downed device */ if (event == NETDEV_DOWN) - ipq_dev_drop(nlq, dev->ifindex); + ipq_dev_drop(dev->ifindex); return NOTIFY_DONE; } -struct notifier_block ipq_dev_notifier = { - receive_event, +static struct notifier_block ipq_dev_notifier = { + ipq_rcv_dev_event, NULL, 0 }; -/**************************************************************************** - * - * Sysctl - queue tuning. - * - ****************************************************************************/ +static int +ipq_rcv_nl_event(struct notifier_block *this, + unsigned long event, void *ptr) +{ + struct netlink_notify *n = ptr; + + if (event == NETLINK_URELEASE && + n->protocol == NETLINK_FIREWALL && n->pid) { + write_lock_bh(&queue_lock); + if (n->pid == peer_pid) + __ipq_reset(); + write_unlock_bh(&queue_lock); + } + return NOTIFY_DONE; +} -static int sysctl_maxlen = IPQ_QMAX_DEFAULT; +static struct notifier_block ipq_nl_notifier = { + ipq_rcv_nl_event, + NULL, + 0 +}; +static int sysctl_maxlen = IPQ_QMAX_DEFAULT; static struct ctl_table_header *ipq_sysctl_header; static ctl_table ipq_table[] = { @@ -574,35 +600,27 @@ static ctl_table ipq_root_table[] = { { 0 } }; -/**************************************************************************** - * - * Procfs - debugging info. - * - ****************************************************************************/ - -static int ipq_get_info(char *buffer, char **start, off_t offset, int length) +static int +ipq_get_info(char *buffer, char **start, off_t offset, int length) { int len; - spin_lock_bh(&nlq->lock); + read_lock_bh(&queue_lock); + len = sprintf(buffer, - "Peer pid : %d\n" - "Peer died : %d\n" - "Peer copy mode : %d\n" - "Peer copy range : %Zu\n" - "Queue length : %d\n" - "Queue max. length : %d\n" - "Queue flushing : %d\n" - "Queue terminate : %d\n", - nlq->peer.pid, - nlq->peer.died, - nlq->peer.copy_mode, - nlq->peer.copy_range, - nlq->len, - *nlq->maxlen, - nlq->flushing, - nlq->terminate); - spin_unlock_bh(&nlq->lock); + "Peer PID : %d\n" + "Copy mode : %hu\n" + "Copy range : %u\n" + "Queue length : %u\n" + "Queue max. length : %u\n", + peer_pid, + copy_mode, + copy_range, + queue_total, + queue_maxlen); + + read_unlock_bh(&queue_lock); + *start = buffer + offset; len -= offset; if (len > length) @@ -612,53 +630,74 @@ static int ipq_get_info(char *buffer, char **start, off_t offset, int length) return len; } -/**************************************************************************** - * - * Module stuff. - * - ****************************************************************************/ - -static int __init init(void) +static int +init_or_cleanup(int init) { - int status = 0; + int status = -ENOMEM; struct proc_dir_entry *proc; - nfnl = netlink_kernel_create(NETLINK_FIREWALL, netlink_receive_user_sk); - if (nfnl == NULL) { - printk(KERN_ERR "ip_queue: initialisation failed: unable to " - "create kernel netlink socket\n"); - return -ENOMEM; - } - nlq = ipq_create_queue(netfilter_receive, - netlink_send_peer, &status, &sysctl_maxlen); - if (nlq == NULL) { - printk(KERN_ERR "ip_queue: initialisation failed: unable to " - "create queue\n"); - sock_release(nfnl->socket); - return status; + if (!init) + goto cleanup; + + netlink_register_notifier(&ipq_nl_notifier); + ipqnl = netlink_kernel_create(NETLINK_FIREWALL, ipq_rcv_sk); + if (ipqnl == NULL) { + printk(KERN_ERR "ip_queue: failed to create netlink socket\n"); + goto cleanup_netlink_notifier; } + proc = proc_net_create(IPQ_PROC_FS_NAME, 0, ipq_get_info); - if (proc) proc->owner = THIS_MODULE; + if (proc) + proc->owner = THIS_MODULE; else { - ipq_destroy_queue(nlq); - sock_release(nfnl->socket); - return -ENOMEM; + printk(KERN_ERR "ip_queue: failed to create proc entry\n"); + goto cleanup_ipqnl; } + register_netdevice_notifier(&ipq_dev_notifier); ipq_sysctl_header = register_sysctl_table(ipq_root_table, 0); + + status = nf_register_queue_handler(PF_INET, ipq_enqueue_packet, NULL); + if (status < 0) { + printk(KERN_ERR "ip_queue: failed to register queue handler\n"); + goto cleanup_sysctl; + } return status; + +cleanup: + nf_unregister_queue_handler(PF_INET); + br_write_lock_bh(BR_NETPROTO_LOCK); + br_write_unlock_bh(BR_NETPROTO_LOCK); + ipq_flush(NF_DROP); + +cleanup_sysctl: + unregister_sysctl_table(ipq_sysctl_header); + unregister_netdevice_notifier(&ipq_dev_notifier); + proc_net_remove(IPQ_PROC_FS_NAME); + +cleanup_ipqnl: + sock_release(ipqnl->socket); + down(&ipqnl_sem); + up(&ipqnl_sem); + +cleanup_netlink_notifier: + netlink_unregister_notifier(&ipq_nl_notifier); + return status; +} + +static int __init init(void) +{ + + return init_or_cleanup(1); } static void __exit fini(void) { - unregister_sysctl_table(ipq_sysctl_header); - proc_net_remove(IPQ_PROC_FS_NAME); - unregister_netdevice_notifier(&ipq_dev_notifier); - ipq_destroy_queue(nlq); - sock_release(nfnl->socket); + init_or_cleanup(0); } MODULE_DESCRIPTION("IPv4 packet queue handler"); +MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>"); MODULE_LICENSE("GPL"); module_init(init); diff --git a/net/ipv4/protocol.c b/net/ipv4/protocol.c index a379decd8311..e04d1ff5fc47 100644 --- a/net/ipv4/protocol.c +++ b/net/ipv4/protocol.c @@ -53,10 +53,10 @@ #ifdef CONFIG_IP_MULTICAST static struct inet_protocol igmp_protocol = { - handler: igmp_rcv, - next: IPPROTO_PREVIOUS, - protocol: IPPROTO_IGMP, - name: "IGMP" + .handler = igmp_rcv, + .next = IPPROTO_PREVIOUS, + .protocol = IPPROTO_IGMP, + .name = "IGMP" }; #undef IPPROTO_PREVIOUS @@ -65,32 +65,32 @@ static struct inet_protocol igmp_protocol = { #endif static struct inet_protocol tcp_protocol = { - handler: tcp_v4_rcv, - err_handler: tcp_v4_err, - next: IPPROTO_PREVIOUS, - protocol: IPPROTO_TCP, - name: "TCP" + .handler = tcp_v4_rcv, + .err_handler = tcp_v4_err, + .next = IPPROTO_PREVIOUS, + .protocol = IPPROTO_TCP, + .name = "TCP" }; #undef IPPROTO_PREVIOUS #define IPPROTO_PREVIOUS &tcp_protocol static struct inet_protocol udp_protocol = { - handler: udp_rcv, - err_handler: udp_err, - next: IPPROTO_PREVIOUS, - protocol: IPPROTO_UDP, - name: "UDP" + .handler = udp_rcv, + .err_handler = udp_err, + .next = IPPROTO_PREVIOUS, + .protocol = IPPROTO_UDP, + .name = "UDP" }; #undef IPPROTO_PREVIOUS #define IPPROTO_PREVIOUS &udp_protocol static struct inet_protocol icmp_protocol = { - handler: icmp_rcv, - next: IPPROTO_PREVIOUS, - protocol: IPPROTO_ICMP, - name: "ICMP" + .handler = icmp_rcv, + .next = IPPROTO_PREVIOUS, + .protocol = IPPROTO_ICMP, + .name = "ICMP" }; #undef IPPROTO_PREVIOUS diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 107267695d83..fb041f49ed9d 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c @@ -688,18 +688,18 @@ out: } struct proto raw_prot = { - name: "RAW", - close: raw_close, - connect: udp_connect, - disconnect: udp_disconnect, - ioctl: raw_ioctl, - init: raw_init, - setsockopt: raw_setsockopt, - getsockopt: raw_getsockopt, - sendmsg: raw_sendmsg, - recvmsg: raw_recvmsg, - bind: raw_bind, - backlog_rcv: raw_rcv_skb, - hash: raw_v4_hash, - unhash: raw_v4_unhash, + .name = "RAW", + .close = raw_close, + .connect = udp_connect, + .disconnect = udp_disconnect, + .ioctl = raw_ioctl, + .init = raw_init, + .setsockopt = raw_setsockopt, + .getsockopt = raw_getsockopt, + .sendmsg = raw_sendmsg, + .recvmsg = raw_recvmsg, + .bind = raw_bind, + .backlog_rcv = raw_rcv_skb, + .hash = raw_v4_hash, + .unhash = raw_v4_unhash, }; diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 464a56367e28..7613b773f1d3 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -139,15 +139,15 @@ static int rt_garbage_collect(void); struct dst_ops ipv4_dst_ops = { - family: AF_INET, - protocol: __constant_htons(ETH_P_IP), - gc: rt_garbage_collect, - check: ipv4_dst_check, - reroute: ipv4_dst_reroute, - destroy: ipv4_dst_destroy, - negative_advice: ipv4_negative_advice, - link_failure: ipv4_link_failure, - entry_size: sizeof(struct rtable), + .family = AF_INET, + .protocol = __constant_htons(ETH_P_IP), + .gc = rt_garbage_collect, + .check = ipv4_dst_check, + .reroute = ipv4_dst_reroute, + .destroy = ipv4_dst_destroy, + .negative_advice = ipv4_negative_advice, + .link_failure = ipv4_link_failure, + .entry_size = sizeof(struct rtable), }; #define ECN_OR_COST(class) TC_PRIO_##class @@ -2267,147 +2267,147 @@ static int ipv4_sysctl_rtcache_flush_strategy(ctl_table *table, int *name, ctl_table ipv4_route_table[] = { { - ctl_name: NET_IPV4_ROUTE_FLUSH, - procname: "flush", - data: &flush_delay, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &ipv4_sysctl_rtcache_flush, - strategy: &ipv4_sysctl_rtcache_flush_strategy, + .ctl_name = NET_IPV4_ROUTE_FLUSH, + .procname = "flush", + .data = &flush_delay, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&ipv4_sysctl_rtcache_flush, + .strategy = &ipv4_sysctl_rtcache_flush_strategy, }, { - ctl_name: NET_IPV4_ROUTE_MIN_DELAY, - procname: "min_delay", - data: &ip_rt_min_delay, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec_jiffies, - strategy: &sysctl_jiffies, + .ctl_name = NET_IPV4_ROUTE_MIN_DELAY, + .procname = "min_delay", + .data = &ip_rt_min_delay, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec_jiffies, + .strategy = &sysctl_jiffies, }, { - ctl_name: NET_IPV4_ROUTE_MAX_DELAY, - procname: "max_delay", - data: &ip_rt_max_delay, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec_jiffies, - strategy: &sysctl_jiffies, + .ctl_name = NET_IPV4_ROUTE_MAX_DELAY, + .procname = "max_delay", + .data = &ip_rt_max_delay, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec_jiffies, + .strategy = &sysctl_jiffies, }, { - ctl_name: NET_IPV4_ROUTE_GC_THRESH, - procname: "gc_thresh", - data: &ipv4_dst_ops.gc_thresh, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_ROUTE_GC_THRESH, + .procname = "gc_thresh", + .data = &ipv4_dst_ops.gc_thresh, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_ROUTE_MAX_SIZE, - procname: "max_size", - data: &ip_rt_max_size, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_ROUTE_MAX_SIZE, + .procname = "max_size", + .data = &ip_rt_max_size, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_ROUTE_GC_MIN_INTERVAL, - procname: "gc_min_interval", - data: &ip_rt_gc_min_interval, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec_jiffies, - strategy: &sysctl_jiffies, + .ctl_name = NET_IPV4_ROUTE_GC_MIN_INTERVAL, + .procname = "gc_min_interval", + .data = &ip_rt_gc_min_interval, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec_jiffies, + .strategy = &sysctl_jiffies, }, { - ctl_name: NET_IPV4_ROUTE_GC_TIMEOUT, - procname: "gc_timeout", - data: &ip_rt_gc_timeout, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec_jiffies, - strategy: &sysctl_jiffies, + .ctl_name = NET_IPV4_ROUTE_GC_TIMEOUT, + .procname = "gc_timeout", + .data = &ip_rt_gc_timeout, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec_jiffies, + .strategy = &sysctl_jiffies, }, { - ctl_name: NET_IPV4_ROUTE_GC_INTERVAL, - procname: "gc_interval", - data: &ip_rt_gc_interval, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec_jiffies, - strategy: &sysctl_jiffies, + .ctl_name = NET_IPV4_ROUTE_GC_INTERVAL, + .procname = "gc_interval", + .data = &ip_rt_gc_interval, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec_jiffies, + .strategy = &sysctl_jiffies, }, { - ctl_name: NET_IPV4_ROUTE_REDIRECT_LOAD, - procname: "redirect_load", - data: &ip_rt_redirect_load, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_ROUTE_REDIRECT_LOAD, + .procname = "redirect_load", + .data = &ip_rt_redirect_load, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_ROUTE_REDIRECT_NUMBER, - procname: "redirect_number", - data: &ip_rt_redirect_number, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_ROUTE_REDIRECT_NUMBER, + .procname = "redirect_number", + .data = &ip_rt_redirect_number, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_ROUTE_REDIRECT_SILENCE, - procname: "redirect_silence", - data: &ip_rt_redirect_silence, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_ROUTE_REDIRECT_SILENCE, + .procname = "redirect_silence", + .data = &ip_rt_redirect_silence, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_ROUTE_ERROR_COST, - procname: "error_cost", - data: &ip_rt_error_cost, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_ROUTE_ERROR_COST, + .procname = "error_cost", + .data = &ip_rt_error_cost, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_ROUTE_ERROR_BURST, - procname: "error_burst", - data: &ip_rt_error_burst, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_ROUTE_ERROR_BURST, + .procname = "error_burst", + .data = &ip_rt_error_burst, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_ROUTE_GC_ELASTICITY, - procname: "gc_elasticity", - data: &ip_rt_gc_elasticity, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_ROUTE_GC_ELASTICITY, + .procname = "gc_elasticity", + .data = &ip_rt_gc_elasticity, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_ROUTE_MTU_EXPIRES, - procname: "mtu_expires", - data: &ip_rt_mtu_expires, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec_jiffies, - strategy: &sysctl_jiffies, + .ctl_name = NET_IPV4_ROUTE_MTU_EXPIRES, + .procname = "mtu_expires", + .data = &ip_rt_mtu_expires, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec_jiffies, + .strategy = &sysctl_jiffies, }, { - ctl_name: NET_IPV4_ROUTE_MIN_PMTU, - procname: "min_pmtu", - data: &ip_rt_min_pmtu, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_ROUTE_MIN_PMTU, + .procname = "min_pmtu", + .data = &ip_rt_min_pmtu, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { - ctl_name: NET_IPV4_ROUTE_MIN_ADVMSS, - procname: "min_adv_mss", - data: &ip_rt_min_advmss, - maxlen: sizeof(int), - mode: 0644, - proc_handler: &proc_dointvec, + .ctl_name = NET_IPV4_ROUTE_MIN_ADVMSS, + .procname = "min_adv_mss", + .data = &ip_rt_min_advmss, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler =&proc_dointvec, }, { 0 } }; @@ -2429,6 +2429,11 @@ static int ip_rt_acct_read(char *buffer, char **start, off_t offset, if ((offset & 3) || (length & 3)) return -EIO; + if (offset >= sizeof(struct ip_rt_acct) * 256) { + *eof = 1; + return 0; + } + if (offset + length >= sizeof(struct ip_rt_acct) * 256) { length = sizeof(struct ip_rt_acct) * 256 - offset; *eof = 1; diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 53c06caf141f..4386163ca3af 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -79,11 +79,11 @@ void tcp_v4_send_check(struct sock *sk, struct tcphdr *th, int len, struct sk_buff *skb); struct tcp_hashinfo __cacheline_aligned tcp_hashinfo = { - __tcp_lhash_lock: RW_LOCK_UNLOCKED, - __tcp_lhash_users: ATOMIC_INIT(0), + .__tcp_lhash_lock = RW_LOCK_UNLOCKED, + .__tcp_lhash_users = ATOMIC_INIT(0), __tcp_lhash_wait: __WAIT_QUEUE_HEAD_INITIALIZER(tcp_hashinfo.__tcp_lhash_wait), - __tcp_portalloc_lock: SPIN_LOCK_UNLOCKED + .__tcp_portalloc_lock = SPIN_LOCK_UNLOCKED }; /* @@ -158,8 +158,8 @@ __inline__ void tcp_inherit_port(struct sock *sk, struct sock *child) local_bh_enable(); } -static inline void tcp_bind_hash(struct sock *sk, struct tcp_bind_bucket *tb, - unsigned short snum) +void tcp_bind_hash(struct sock *sk, struct tcp_bind_bucket *tb, + unsigned short snum) { inet_sk(sk)->num = snum; if ((sk->bind_next = tb->owners) != NULL) @@ -1379,11 +1379,11 @@ static inline struct ip_options *tcp_v4_save_options(struct sock *sk, int sysctl_max_syn_backlog = 256; struct or_calltable or_ipv4 = { - family: PF_INET, - rtx_syn_ack: tcp_v4_send_synack, - send_ack: tcp_v4_or_send_ack, - destructor: tcp_v4_or_free, - send_reset: tcp_v4_send_reset, + .family = PF_INET, + .rtx_syn_ack = tcp_v4_send_synack, + .send_ack = tcp_v4_or_send_ack, + .destructor = tcp_v4_or_free, + .send_reset = tcp_v4_send_reset, }; int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) @@ -1998,17 +1998,17 @@ int tcp_v4_tw_remember_stamp(struct tcp_tw_bucket *tw) } struct tcp_func ipv4_specific = { - queue_xmit: ip_queue_xmit, - send_check: tcp_v4_send_check, - rebuild_header: tcp_v4_rebuild_header, - conn_request: tcp_v4_conn_request, - syn_recv_sock: tcp_v4_syn_recv_sock, - remember_stamp: tcp_v4_remember_stamp, - net_header_len: sizeof(struct iphdr), - setsockopt: ip_setsockopt, - getsockopt: ip_getsockopt, - addr2sockaddr: v4_addr2sockaddr, - sockaddr_len: sizeof(struct sockaddr_in), + .queue_xmit = ip_queue_xmit, + .send_check = tcp_v4_send_check, + .rebuild_header =tcp_v4_rebuild_header, + .conn_request = tcp_v4_conn_request, + .syn_recv_sock =tcp_v4_syn_recv_sock, + .remember_stamp =tcp_v4_remember_stamp, + .net_header_len =sizeof(struct iphdr), + .setsockopt = ip_setsockopt, + .getsockopt = ip_getsockopt, + .addr2sockaddr =v4_addr2sockaddr, + .sockaddr_len = sizeof(struct sockaddr_in), }; /* NOTE: A lot of things set to zero explicitly by call to @@ -2305,23 +2305,23 @@ out_no_bh: } struct proto tcp_prot = { - name: "TCP", - close: tcp_close, - connect: tcp_v4_connect, - disconnect: tcp_disconnect, - accept: tcp_accept, - ioctl: tcp_ioctl, - init: tcp_v4_init_sock, - destroy: tcp_v4_destroy_sock, - shutdown: tcp_shutdown, - setsockopt: tcp_setsockopt, - getsockopt: tcp_getsockopt, - sendmsg: tcp_sendmsg, - recvmsg: tcp_recvmsg, - backlog_rcv: tcp_v4_do_rcv, - hash: tcp_v4_hash, - unhash: tcp_unhash, - get_port: tcp_v4_get_port, + .name = "TCP", + .close = tcp_close, + .connect = tcp_v4_connect, + .disconnect = tcp_disconnect, + .accept = tcp_accept, + .ioctl = tcp_ioctl, + .init = tcp_v4_init_sock, + .destroy = tcp_v4_destroy_sock, + .shutdown = tcp_shutdown, + .setsockopt = tcp_setsockopt, + .getsockopt = tcp_getsockopt, + .sendmsg = tcp_sendmsg, + .recvmsg = tcp_recvmsg, + .backlog_rcv = tcp_v4_do_rcv, + .hash = tcp_v4_hash, + .unhash = tcp_unhash, + .get_port = tcp_v4_get_port, }; diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index c67ea0c1191b..04fbbc04f53b 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1039,17 +1039,17 @@ out: } struct proto udp_prot = { - name: "UDP", - close: udp_close, - connect: udp_connect, - disconnect: udp_disconnect, - ioctl: udp_ioctl, - setsockopt: ip_setsockopt, - getsockopt: ip_getsockopt, - sendmsg: udp_sendmsg, - recvmsg: udp_recvmsg, - backlog_rcv: udp_queue_rcv_skb, - hash: udp_v4_hash, - unhash: udp_v4_unhash, - get_port: udp_v4_get_port, + .name = "UDP", + .close = udp_close, + .connect = udp_connect, + .disconnect = udp_disconnect, + .ioctl = udp_ioctl, + .setsockopt = ip_setsockopt, + .getsockopt = ip_getsockopt, + .sendmsg = udp_sendmsg, + .recvmsg = udp_recvmsg, + .backlog_rcv = udp_queue_rcv_skb, + .hash = udp_v4_hash, + .unhash = udp_v4_unhash, + .get_port = udp_v4_get_port, }; diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index ef18c7f59ffb..fbe45634e28b 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -506,50 +506,50 @@ static int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) } struct proto_ops inet6_stream_ops = { - family: PF_INET6, - - release: inet6_release, - bind: inet6_bind, - connect: inet_stream_connect, /* ok */ - socketpair: sock_no_socketpair, /* a do nothing */ - accept: inet_accept, /* ok */ - getname: inet6_getname, - poll: tcp_poll, /* ok */ - ioctl: inet6_ioctl, /* must change */ - listen: inet_listen, /* ok */ - shutdown: inet_shutdown, /* ok */ - setsockopt: inet_setsockopt, /* ok */ - getsockopt: inet_getsockopt, /* ok */ - sendmsg: inet_sendmsg, /* ok */ - recvmsg: inet_recvmsg, /* ok */ - mmap: sock_no_mmap, - sendpage: tcp_sendpage + .family = PF_INET6, + + .release = inet6_release, + .bind = inet6_bind, + .connect = inet_stream_connect, /* ok */ + .socketpair = sock_no_socketpair, /* a do nothing */ + .accept = inet_accept, /* ok */ + .getname = inet6_getname, + .poll = tcp_poll, /* ok */ + .ioctl = inet6_ioctl, /* must change */ + .listen = inet_listen, /* ok */ + .shutdown = inet_shutdown, /* ok */ + .setsockopt = inet_setsockopt, /* ok */ + .getsockopt = inet_getsockopt, /* ok */ + .sendmsg = inet_sendmsg, /* ok */ + .recvmsg = inet_recvmsg, /* ok */ + .mmap = sock_no_mmap, + .sendpage = tcp_sendpage }; struct proto_ops inet6_dgram_ops = { - family: PF_INET6, - - release: inet6_release, - bind: inet6_bind, - connect: inet_dgram_connect, /* ok */ - socketpair: sock_no_socketpair, /* a do nothing */ - accept: sock_no_accept, /* a do nothing */ - getname: inet6_getname, - poll: datagram_poll, /* ok */ - ioctl: inet6_ioctl, /* must change */ - listen: sock_no_listen, /* ok */ - shutdown: inet_shutdown, /* ok */ - setsockopt: inet_setsockopt, /* ok */ - getsockopt: inet_getsockopt, /* ok */ - sendmsg: inet_sendmsg, /* ok */ - recvmsg: inet_recvmsg, /* ok */ - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_INET6, + + .release = inet6_release, + .bind = inet6_bind, + .connect = inet_dgram_connect, /* ok */ + .socketpair = sock_no_socketpair, /* a do nothing */ + .accept = sock_no_accept, /* a do nothing */ + .getname = inet6_getname, + .poll = datagram_poll, /* ok */ + .ioctl = inet6_ioctl, /* must change */ + .listen = sock_no_listen, /* ok */ + .shutdown = inet_shutdown, /* ok */ + .setsockopt = inet_setsockopt, /* ok */ + .getsockopt = inet_getsockopt, /* ok */ + .sendmsg = inet_sendmsg, /* ok */ + .recvmsg = inet_recvmsg, /* ok */ + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; static struct net_proto_family inet6_family_ops = { - family: PF_INET6, - create: inet6_create, + .family =PF_INET6, + .create =inet6_create, }; #ifdef MODULE @@ -567,13 +567,13 @@ extern void ipv6_sysctl_unregister(void); #endif static struct inet_protosw rawv6_protosw = { - type: SOCK_RAW, - protocol: IPPROTO_IP, /* wild card */ - prot: &rawv6_prot, - ops: &inet6_dgram_ops, - capability: CAP_NET_RAW, - no_check: UDP_CSUM_DEFAULT, - flags: INET_PROTOSW_REUSE, + .type = SOCK_RAW, + .protocol = IPPROTO_IP, /* wild card */ + .prot = &rawv6_prot, + .ops = &inet6_dgram_ops, + .capability =CAP_NET_RAW, + .no_check = UDP_CSUM_DEFAULT, + .flags = INET_PROTOSW_REUSE, }; #define INETSW6_ARRAY_LEN (sizeof(inetsw6_array) / sizeof(struct inet_protosw)) diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 3724b0fe42db..3f26f406029a 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -85,62 +85,62 @@ static void pndisc_destructor(struct pneigh_entry *n); static void pndisc_redo(struct sk_buff *skb); static struct neigh_ops ndisc_generic_ops = { - family: AF_INET6, - solicit: ndisc_solicit, - error_report: ndisc_error_report, - output: neigh_resolve_output, - connected_output: neigh_connected_output, - hh_output: dev_queue_xmit, - queue_xmit: dev_queue_xmit, + .family = AF_INET6, + .solicit = ndisc_solicit, + .error_report = ndisc_error_report, + .output = neigh_resolve_output, + .connected_output = neigh_connected_output, + .hh_output = dev_queue_xmit, + .queue_xmit = dev_queue_xmit, }; static struct neigh_ops ndisc_hh_ops = { - family: AF_INET6, - solicit: ndisc_solicit, - error_report: ndisc_error_report, - output: neigh_resolve_output, - connected_output: neigh_resolve_output, - hh_output: dev_queue_xmit, - queue_xmit: dev_queue_xmit, + .family = AF_INET6, + .solicit = ndisc_solicit, + .error_report = ndisc_error_report, + .output = neigh_resolve_output, + .connected_output = neigh_resolve_output, + .hh_output = dev_queue_xmit, + .queue_xmit = dev_queue_xmit, }; static struct neigh_ops ndisc_direct_ops = { - family: AF_INET6, - output: dev_queue_xmit, - connected_output: dev_queue_xmit, - hh_output: dev_queue_xmit, - queue_xmit: dev_queue_xmit, + .family = AF_INET6, + .output = dev_queue_xmit, + .connected_output = dev_queue_xmit, + .hh_output = dev_queue_xmit, + .queue_xmit = dev_queue_xmit, }; struct neigh_table nd_tbl = { - family: AF_INET6, - entry_size: sizeof(struct neighbour) + sizeof(struct in6_addr), - key_len: sizeof(struct in6_addr), - hash: ndisc_hash, - constructor: ndisc_constructor, - pconstructor: pndisc_constructor, - pdestructor: pndisc_destructor, - proxy_redo: pndisc_redo, - id: "ndisc_cache", - parms: { - tbl: &nd_tbl, - base_reachable_time: 30 * HZ, - retrans_time: 1 * HZ, - gc_staletime: 60 * HZ, - reachable_time: 30 * HZ, - delay_probe_time: 5 * HZ, - queue_len: 3, - ucast_probes: 3, - mcast_probes: 3, - anycast_delay: 1 * HZ, - proxy_delay: (8 * HZ) / 10, - proxy_qlen: 64, + .family = AF_INET6, + .entry_size = sizeof(struct neighbour) + sizeof(struct in6_addr), + .key_len = sizeof(struct in6_addr), + .hash = ndisc_hash, + .constructor = ndisc_constructor, + .pconstructor = pndisc_constructor, + .pdestructor = pndisc_destructor, + .proxy_redo = pndisc_redo, + .id = "ndisc_cache", + .parms = { + .tbl = &nd_tbl, + .base_reachable_time = 30 * HZ, + .retrans_time = 1 * HZ, + .gc_staletime = 60 * HZ, + .reachable_time = 30 * HZ, + .delay_probe_time = 5 * HZ, + .queue_len = 3, + .ucast_probes = 3, + .mcast_probes = 3, + .anycast_delay = 1 * HZ, + .proxy_delay = (8 * HZ) / 10, + .proxy_qlen = 64, }, - gc_interval: 30 * HZ, - gc_thresh1: 128, - gc_thresh2: 512, - gc_thresh3: 1024, + .gc_interval = 30 * HZ, + .gc_thresh1 = 128, + .gc_thresh2 = 512, + .gc_thresh3 = 1024, }; #define NDISC_OPT_SPACE(len) (((len)+2+7)&~7) diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 893adf62be23..c4f58dcf827c 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -912,19 +912,19 @@ out: } struct proto rawv6_prot = { - name: "RAW", - close: rawv6_close, - connect: udpv6_connect, - disconnect: udp_disconnect, - ioctl: rawv6_ioctl, - init: rawv6_init_sk, - destroy: inet6_destroy_sock, - setsockopt: rawv6_setsockopt, - getsockopt: rawv6_getsockopt, - sendmsg: rawv6_sendmsg, - recvmsg: rawv6_recvmsg, - bind: rawv6_bind, - backlog_rcv: rawv6_rcv_skb, - hash: raw_v6_hash, - unhash: raw_v6_unhash, + .name = "RAW", + .close = rawv6_close, + .connect = udpv6_connect, + .disconnect = udp_disconnect, + .ioctl = rawv6_ioctl, + .init = rawv6_init_sk, + .destroy = inet6_destroy_sock, + .setsockopt = rawv6_setsockopt, + .getsockopt = rawv6_getsockopt, + .sendmsg = rawv6_sendmsg, + .recvmsg = rawv6_recvmsg, + .bind = rawv6_bind, + .backlog_rcv = rawv6_rcv_skb, + .hash = raw_v6_hash, + .unhash = raw_v6_unhash, }; diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 693d8fbb91b9..223c8dbbac95 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c @@ -64,8 +64,8 @@ static int ipip6_fb_tunnel_init(struct net_device *dev); static int ipip6_tunnel_init(struct net_device *dev); static struct net_device ipip6_fb_tunnel_dev = { - name: "sit0", - init: ipip6_fb_tunnel_init + .name = "sit0", + .init = ipip6_fb_tunnel_init }; static struct ip_tunnel ipip6_fb_tunnel = { diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 64cb4aa69bd2..141dd70cdadd 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -85,6 +85,37 @@ static __inline__ int tcp_v6_sk_hashfn(struct sock *sk) return tcp_v6_hashfn(laddr, lport, faddr, fport); } +static inline int ipv6_rcv_saddr_equal(struct sock *sk, struct sock *sk2) +{ + struct ipv6_pinfo *np = inet6_sk(sk); + int addr_type = ipv6_addr_type(&np->rcv_saddr); + + return !inet_sk(sk2)->rcv_saddr || addr_type == IPV6_ADDR_ANY || + (sk2->family == AF_INET6 && + !ipv6_addr_cmp(&np->rcv_saddr, + sk2->state != TCP_TIME_WAIT ? + &inet6_sk(sk2)->rcv_saddr : + &((struct tcp_tw_bucket *)sk)->v6_rcv_saddr)) || + (addr_type == IPV6_ADDR_MAPPED && sk2->family == AF_INET && + inet_sk(sk)->rcv_saddr == inet_sk(sk2)->rcv_saddr); +} + +static inline int tcp_v6_bind_conflict(struct sock *sk, + struct tcp_bind_bucket *tb) +{ + struct sock *sk2 = tb->owners; + + /* We must walk the whole port owner list in this case. -DaveM */ + for (; sk2; sk2 = sk2->bind_next) + if (sk != sk2 && sk->bound_dev_if == sk2->bound_dev_if && + (!sk->reuse || !sk2->reuse || + sk2->state == TCP_LISTEN) && + ipv6_rcv_saddr_equal(sk, sk2)) + break; + + return sk2 != NULL; +} + /* Grrr, addr_type already calculated by caller, but I don't want * to add some silly "cookie" argument to this method just for that. * But it doesn't matter, the recalculation is in the rarest path @@ -139,44 +170,15 @@ static int tcp_v6_get_port(struct sock *sk, unsigned short snum) if (tb->fastreuse > 0 && sk->reuse != 0 && sk->state != TCP_LISTEN) { goto success; } else { - struct ipv6_pinfo *np = inet6_sk(sk); - struct sock *sk2 = tb->owners; - int sk_reuse = sk->reuse; - int addr_type = ipv6_addr_type(&np->rcv_saddr); - - /* We must walk the whole port owner list in this case. -DaveM */ - for( ; sk2 != NULL; sk2 = sk2->bind_next) { - struct ipv6_pinfo *np2 = inet6_sk(sk2); - - if (sk != sk2 && - sk->bound_dev_if == sk2->bound_dev_if) { - if (!sk_reuse || - !sk2->reuse || - sk2->state == TCP_LISTEN) { - /* NOTE: IPv6 tw bucket have different format */ - if (!inet_sk(sk2)->rcv_saddr || - addr_type == IPV6_ADDR_ANY || - !ipv6_addr_cmp(&np->rcv_saddr, - sk2->state != TCP_TIME_WAIT ? - &np2->rcv_saddr : - &((struct tcp_tw_bucket*)sk)->v6_rcv_saddr) || - (addr_type==IPV6_ADDR_MAPPED && sk2->family==AF_INET && - inet_sk(sk)->rcv_saddr == - inet_sk(sk2)->rcv_saddr)) - break; - } - } - } - /* If we found a conflict, fail. */ ret = 1; - if (sk2 != NULL) + if (tcp_v6_bind_conflict(sk, tb)) goto fail_unlock; } } ret = 1; if (tb == NULL && (tb = tcp_bucket_create(head, snum)) == NULL) - goto fail_unlock; + goto fail_unlock; if (tb->owners == NULL) { if (sk->reuse && sk->state != TCP_LISTEN) tb->fastreuse = 1; @@ -187,16 +189,9 @@ static int tcp_v6_get_port(struct sock *sk, unsigned short snum) tb->fastreuse = 0; success: - inet_sk(sk)->num = snum; - if (sk->prev == NULL) { - if ((sk->bind_next = tb->owners) != NULL) - tb->owners->bind_pprev = &sk->bind_next; - tb->owners = sk; - sk->bind_pprev = &tb->owners; - sk->prev = (struct sock *) tb; - } else { - BUG_TRAP(sk->prev == (struct sock *) tb); - } + if (!sk->prev) + tcp_bind_hash(sk, tb, snum); + BUG_TRAP(sk->prev == (struct sock *)tb); ret = 0; fail_unlock: @@ -413,7 +408,7 @@ static __inline__ u16 tcp_v6_check(struct tcphdr *th, int len, static __u32 tcp_v6_init_sequence(struct sock *sk, struct sk_buff *skb) { - if (skb->protocol == __constant_htons(ETH_P_IPV6)) { + if (skb->protocol == htons(ETH_P_IPV6)) { return secure_tcpv6_sequence_number(skb->nh.ipv6h->daddr.s6_addr32, skb->nh.ipv6h->saddr.s6_addr32, skb->h.th->dest, @@ -1051,10 +1046,8 @@ static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 if (ts) { u32 *ptr = (u32*)(t1 + 1); - *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | - (TCPOPT_NOP << 16) | - (TCPOPT_TIMESTAMP << 8) | - TCPOLEN_TIMESTAMP); + *ptr++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); *ptr++ = htonl(tcp_time_stamp); *ptr = htonl(ts); } @@ -1166,7 +1159,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) struct open_request *req = NULL; __u32 isn = TCP_SKB_CB(skb)->when; - if (skb->protocol == __constant_htons(ETH_P_IP)) + if (skb->protocol == htons(ETH_P_IP)) return tcp_v4_conn_request(sk, skb); /* FIXME: do the same check for anycast */ @@ -1247,7 +1240,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, struct sock *newsk; struct ipv6_txoptions *opt; - if (skb->protocol == __constant_htons(ETH_P_IP)) { + if (skb->protocol == htons(ETH_P_IP)) { /* * v6 mapped */ @@ -1463,7 +1456,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) tcp_v6_hnd_req and tcp_v6_send_reset(). --ANK */ - if (skb->protocol == __constant_htons(ETH_P_IP)) + if (skb->protocol == htons(ETH_P_IP)) return tcp_v4_do_rcv(sk, skb); #ifdef CONFIG_FILTER @@ -1784,7 +1777,7 @@ static void v6_addr2sockaddr(struct sock *sk, struct sockaddr * uaddr) struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) uaddr; sin6->sin6_family = AF_INET6; - memcpy(&sin6->sin6_addr, &np->daddr, sizeof(struct in6_addr)); + ipv6_addr_copy(&sin6->sin6_addr, &np->daddr); sin6->sin6_port = inet_sk(sk)->dport; /* We do not store received flowlabel for TCP */ sin6->sin6_flowinfo = 0; @@ -2144,43 +2137,43 @@ out_no_bh: } struct proto tcpv6_prot = { - name: "TCPv6", - close: tcp_close, - connect: tcp_v6_connect, - disconnect: tcp_disconnect, - accept: tcp_accept, - ioctl: tcp_ioctl, - init: tcp_v6_init_sock, - destroy: tcp_v6_destroy_sock, - shutdown: tcp_shutdown, - setsockopt: tcp_setsockopt, - getsockopt: tcp_getsockopt, - sendmsg: tcp_sendmsg, - recvmsg: tcp_recvmsg, - backlog_rcv: tcp_v6_do_rcv, - hash: tcp_v6_hash, - unhash: tcp_unhash, - get_port: tcp_v6_get_port, + .name = "TCPv6", + .close = tcp_close, + .connect = tcp_v6_connect, + .disconnect = tcp_disconnect, + .accept = tcp_accept, + .ioctl = tcp_ioctl, + .init = tcp_v6_init_sock, + .destroy = tcp_v6_destroy_sock, + .shutdown = tcp_shutdown, + .setsockopt = tcp_setsockopt, + .getsockopt = tcp_getsockopt, + .sendmsg = tcp_sendmsg, + .recvmsg = tcp_recvmsg, + .backlog_rcv = tcp_v6_do_rcv, + .hash = tcp_v6_hash, + .unhash = tcp_unhash, + .get_port = tcp_v6_get_port, }; static struct inet6_protocol tcpv6_protocol = { - handler: tcp_v6_rcv, - err_handler: tcp_v6_err, - protocol: IPPROTO_TCP, - name: "TCPv6", + .handler = tcp_v6_rcv, + .err_handler = tcp_v6_err, + .protocol = IPPROTO_TCP, + .name = "TCPv6", }; extern struct proto_ops inet6_stream_ops; static struct inet_protosw tcpv6_protosw = { - type: SOCK_STREAM, - protocol: IPPROTO_TCP, - prot: &tcpv6_prot, - ops: &inet6_stream_ops, - capability: -1, - no_check: 0, - flags: INET_PROTOSW_PERMANENT, + .type = SOCK_STREAM, + .protocol = IPPROTO_TCP, + .prot = &tcpv6_prot, + .ops = &inet6_stream_ops, + .capability =-1, + .no_check = 0, + .flags = INET_PROTOSW_PERMANENT, }; void __init tcpv6_init(void) diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 988fa8b0ca40..245b3a78c18b 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -905,10 +905,10 @@ static int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, int ulen) } static struct inet6_protocol udpv6_protocol = { - handler: udpv6_rcv, - err_handler: udpv6_err, - protocol: IPPROTO_UDP, - name: "UDPv6", + .handler = udpv6_rcv, + .err_handler = udpv6_err, + .protocol = IPPROTO_UDP, + .name = "UDPv6", }; #define LINE_LEN 190 @@ -987,32 +987,32 @@ out: } struct proto udpv6_prot = { - name: "UDP", - close: udpv6_close, - connect: udpv6_connect, - disconnect: udp_disconnect, - ioctl: udp_ioctl, - destroy: inet6_destroy_sock, - setsockopt: ipv6_setsockopt, - getsockopt: ipv6_getsockopt, - sendmsg: udpv6_sendmsg, - recvmsg: udpv6_recvmsg, - backlog_rcv: udpv6_queue_rcv_skb, - hash: udp_v6_hash, - unhash: udp_v6_unhash, - get_port: udp_v6_get_port, + .name = "UDP", + .close = udpv6_close, + .connect = udpv6_connect, + .disconnect = udp_disconnect, + .ioctl = udp_ioctl, + .destroy = inet6_destroy_sock, + .setsockopt = ipv6_setsockopt, + .getsockopt = ipv6_getsockopt, + .sendmsg = udpv6_sendmsg, + .recvmsg = udpv6_recvmsg, + .backlog_rcv = udpv6_queue_rcv_skb, + .hash = udp_v6_hash, + .unhash = udp_v6_unhash, + .get_port = udp_v6_get_port, }; extern struct proto_ops inet6_dgram_ops; static struct inet_protosw udpv6_protosw = { - type: SOCK_DGRAM, - protocol: IPPROTO_UDP, - prot: &udpv6_prot, - ops: &inet6_dgram_ops, - capability: -1, - no_check: UDP_CSUM_DEFAULT, - flags: INET_PROTOSW_PERMANENT, + .type = SOCK_DGRAM, + .protocol = IPPROTO_UDP, + .prot = &udpv6_prot, + .ops = &inet6_dgram_ops, + .capability =-1, + .no_check = UDP_CSUM_DEFAULT, + .flags = INET_PROTOSW_PERMANENT, }; diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index b437540cf5d0..2577ad82185c 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c @@ -2496,48 +2496,48 @@ int ipx_unregister_spx(void) */ static struct net_proto_family ipx_family_ops = { - family: PF_IPX, - create: ipx_create, + .family = PF_IPX, + .create = ipx_create, }; static struct proto_ops SOCKOPS_WRAPPED(ipx_dgram_ops) = { - family: PF_IPX, - - release: ipx_release, - bind: ipx_bind, - connect: ipx_connect, - socketpair: sock_no_socketpair, - accept: sock_no_accept, - getname: ipx_getname, - poll: datagram_poll, - ioctl: ipx_ioctl, - listen: sock_no_listen, - shutdown: sock_no_shutdown, /* FIXME: have to support shutdown */ - setsockopt: ipx_setsockopt, - getsockopt: ipx_getsockopt, - sendmsg: ipx_sendmsg, - recvmsg: ipx_recvmsg, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_IPX, + + .release = ipx_release, + .bind = ipx_bind, + .connect = ipx_connect, + .socketpair = sock_no_socketpair, + .accept = sock_no_accept, + .getname = ipx_getname, + .poll = datagram_poll, + .ioctl = ipx_ioctl, + .listen = sock_no_listen, + .shutdown = sock_no_shutdown, /* FIXME: have to support shutdown */ + .setsockopt = ipx_setsockopt, + .getsockopt = ipx_getsockopt, + .sendmsg = ipx_sendmsg, + .recvmsg = ipx_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; #include <linux/smp_lock.h> SOCKOPS_WRAP(ipx_dgram, PF_IPX); static struct packet_type ipx_8023_packet_type = { - type: __constant_htons(ETH_P_802_3), - func: ipx_rcv, - data: (void *) 1, /* yap, I understand shared skbs :-) */ + .type = __constant_htons(ETH_P_802_3), + .func = ipx_rcv, + .data = (void *) 1, /* yap, I understand shared skbs :-) */ }; static struct packet_type ipx_dix_packet_type = { - type: __constant_htons(ETH_P_IPX), - func: ipx_rcv, - data: (void *) 1, /* yap, I understand shared skbs :-) */ + .type = __constant_htons(ETH_P_IPX), + .func = ipx_rcv, + .data = (void *) 1, /* yap, I understand shared skbs :-) */ }; static struct notifier_block ipx_dev_notifier = { - notifier_call: ipxitf_device_event, + .notifier_call =ipxitf_device_event, }; diff --git a/net/ipx/af_spx.c b/net/ipx/af_spx.c index a844c082d796..761225f007f0 100644 --- a/net/ipx/af_spx.c +++ b/net/ipx/af_spx.c @@ -833,32 +833,32 @@ static int spx_getsockopt(struct socket *sock, int level, int optname, } static struct proto_ops SOCKOPS_WRAPPED(spx_ops) = { - family: PF_IPX, - - release: spx_release, - bind: spx_bind, - connect: spx_connect, - socketpair: sock_no_socketpair, - accept: spx_accept, - getname: spx_getname, - poll: spx_datagram_poll, - ioctl: spx_ioctl, - listen: spx_listen, - shutdown: sock_no_shutdown, - setsockopt: spx_setsockopt, - getsockopt: spx_getsockopt, - sendmsg: spx_sendmsg, - recvmsg: spx_recvmsg, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_IPX, + + .release = spx_release, + .bind = spx_bind, + .connect = spx_connect, + .socketpair = sock_no_socketpair, + .accept = spx_accept, + .getname = spx_getname, + .poll = spx_datagram_poll, + .ioctl = spx_ioctl, + .listen = spx_listen, + .shutdown = sock_no_shutdown, + .setsockopt = spx_setsockopt, + .getsockopt = spx_getsockopt, + .sendmsg = spx_sendmsg, + .recvmsg = spx_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; #include <linux/smp_lock.h> SOCKOPS_WRAP(spx, PF_IPX); static struct net_proto_family spx_family_ops = { - family: PF_IPX, - create: spx_create, + .family = PF_IPX, + .create = spx_create, }; static char banner[] __initdata = diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index 87aaa492c545..c37c0118096f 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c @@ -2414,93 +2414,93 @@ bed: } static struct net_proto_family irda_family_ops = { - family: PF_IRDA, - create: irda_create, + .family =PF_IRDA, + .create =irda_create, }; static struct proto_ops SOCKOPS_WRAPPED(irda_stream_ops) = { - family: PF_IRDA, - - release: irda_release, - bind: irda_bind, - connect: irda_connect, - socketpair: sock_no_socketpair, - accept: irda_accept, - getname: irda_getname, - poll: irda_poll, - ioctl: irda_ioctl, - listen: irda_listen, - shutdown: irda_shutdown, - setsockopt: irda_setsockopt, - getsockopt: irda_getsockopt, - sendmsg: irda_sendmsg, - recvmsg: irda_recvmsg_stream, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_IRDA, + + .release = irda_release, + .bind = irda_bind, + .connect = irda_connect, + .socketpair = sock_no_socketpair, + .accept = irda_accept, + .getname = irda_getname, + .poll = irda_poll, + .ioctl = irda_ioctl, + .listen = irda_listen, + .shutdown = irda_shutdown, + .setsockopt = irda_setsockopt, + .getsockopt = irda_getsockopt, + .sendmsg = irda_sendmsg, + .recvmsg = irda_recvmsg_stream, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; static struct proto_ops SOCKOPS_WRAPPED(irda_seqpacket_ops) = { - family: PF_IRDA, - - release: irda_release, - bind: irda_bind, - connect: irda_connect, - socketpair: sock_no_socketpair, - accept: irda_accept, - getname: irda_getname, - poll: datagram_poll, - ioctl: irda_ioctl, - listen: irda_listen, - shutdown: irda_shutdown, - setsockopt: irda_setsockopt, - getsockopt: irda_getsockopt, - sendmsg: irda_sendmsg, - recvmsg: irda_recvmsg_dgram, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_IRDA, + + .release = irda_release, + .bind = irda_bind, + .connect = irda_connect, + .socketpair = sock_no_socketpair, + .accept = irda_accept, + .getname = irda_getname, + .poll = datagram_poll, + .ioctl = irda_ioctl, + .listen = irda_listen, + .shutdown = irda_shutdown, + .setsockopt = irda_setsockopt, + .getsockopt = irda_getsockopt, + .sendmsg = irda_sendmsg, + .recvmsg = irda_recvmsg_dgram, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; static struct proto_ops SOCKOPS_WRAPPED(irda_dgram_ops) = { - family: PF_IRDA, - - release: irda_release, - bind: irda_bind, - connect: irda_connect, - socketpair: sock_no_socketpair, - accept: irda_accept, - getname: irda_getname, - poll: datagram_poll, - ioctl: irda_ioctl, - listen: irda_listen, - shutdown: irda_shutdown, - setsockopt: irda_setsockopt, - getsockopt: irda_getsockopt, - sendmsg: irda_sendmsg_dgram, - recvmsg: irda_recvmsg_dgram, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_IRDA, + + .release = irda_release, + .bind = irda_bind, + .connect = irda_connect, + .socketpair = sock_no_socketpair, + .accept = irda_accept, + .getname = irda_getname, + .poll = datagram_poll, + .ioctl = irda_ioctl, + .listen = irda_listen, + .shutdown = irda_shutdown, + .setsockopt = irda_setsockopt, + .getsockopt = irda_getsockopt, + .sendmsg = irda_sendmsg_dgram, + .recvmsg = irda_recvmsg_dgram, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; #ifdef CONFIG_IRDA_ULTRA static struct proto_ops SOCKOPS_WRAPPED(irda_ultra_ops) = { - family: PF_IRDA, - - release: irda_release, - bind: irda_bind, - connect: sock_no_connect, - socketpair: sock_no_socketpair, - accept: sock_no_accept, - getname: irda_getname, - poll: datagram_poll, - ioctl: irda_ioctl, - listen: sock_no_listen, - shutdown: irda_shutdown, - setsockopt: irda_setsockopt, - getsockopt: irda_getsockopt, - sendmsg: irda_sendmsg_ultra, - recvmsg: irda_recvmsg_dgram, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_IRDA, + + .release = irda_release, + .bind = irda_bind, + .connect = sock_no_connect, + .socketpair = sock_no_socketpair, + .accept = sock_no_accept, + .getname = irda_getname, + .poll = datagram_poll, + .ioctl = irda_ioctl, + .listen = sock_no_listen, + .shutdown = irda_shutdown, + .setsockopt = irda_setsockopt, + .getsockopt = irda_getsockopt, + .sendmsg = irda_sendmsg_ultra, + .recvmsg = irda_recvmsg_dgram, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; #endif /* CONFIG_IRDA_ULTRA */ diff --git a/net/llc/llc_c_st.c b/net/llc/llc_c_st.c index ef52dc23ad13..fb938c640392 100644 --- a/net/llc/llc_c_st.c +++ b/net/llc/llc_c_st.c @@ -4896,51 +4896,51 @@ static struct llc_conn_state_trans *llc_temp_state_transitions[] = { /* Connection State Transition Table */ struct llc_conn_state llc_conn_state_table[] = { { - current_state: LLC_CONN_STATE_ADM, - transitions: llc_adm_state_transitions, + .current_state =LLC_CONN_STATE_ADM, + .transitions = llc_adm_state_transitions, }, { - current_state: LLC_CONN_STATE_SETUP, - transitions: llc_setup_state_transitions, + .current_state =LLC_CONN_STATE_SETUP, + .transitions = llc_setup_state_transitions, }, { - current_state: LLC_CONN_STATE_NORMAL, - transitions: llc_normal_state_transitions, + .current_state =LLC_CONN_STATE_NORMAL, + .transitions = llc_normal_state_transitions, }, { - current_state: LLC_CONN_STATE_BUSY, - transitions: llc_busy_state_transitions, + .current_state =LLC_CONN_STATE_BUSY, + .transitions = llc_busy_state_transitions, }, { - current_state: LLC_CONN_STATE_REJ, - transitions: llc_reject_state_transitions, + .current_state =LLC_CONN_STATE_REJ, + .transitions = llc_reject_state_transitions, }, { - current_state: LLC_CONN_STATE_AWAIT, - transitions: llc_await_state_transitions, + .current_state =LLC_CONN_STATE_AWAIT, + .transitions = llc_await_state_transitions, }, { - current_state: LLC_CONN_STATE_AWAIT_BUSY, - transitions: llc_await_busy_state_transitions, + .current_state =LLC_CONN_STATE_AWAIT_BUSY, + .transitions = llc_await_busy_state_transitions, }, { - current_state: LLC_CONN_STATE_AWAIT_REJ, - transitions: llc_await_rejct_state_transitions, + .current_state =LLC_CONN_STATE_AWAIT_REJ, + .transitions = llc_await_rejct_state_transitions, }, { - current_state: LLC_CONN_STATE_D_CONN, - transitions: llc_d_conn_state_transitions, + .current_state =LLC_CONN_STATE_D_CONN, + .transitions = llc_d_conn_state_transitions, }, { - current_state: LLC_CONN_STATE_RESET, - transitions: llc_rst_state_transitions, + .current_state =LLC_CONN_STATE_RESET, + .transitions = llc_rst_state_transitions, }, { - current_state: LLC_CONN_STATE_ERROR, - transitions: llc_error_state_transitions, + .current_state =LLC_CONN_STATE_ERROR, + .transitions = llc_error_state_transitions, }, { - current_state: LLC_CONN_STATE_TEMP, - transitions: llc_temp_state_transitions, + .current_state =LLC_CONN_STATE_TEMP, + .transitions = llc_temp_state_transitions, }, }; diff --git a/net/llc/llc_s_st.c b/net/llc/llc_s_st.c index 1c93ac638802..1dfcf1abb2f7 100644 --- a/net/llc/llc_s_st.c +++ b/net/llc/llc_s_st.c @@ -173,11 +173,11 @@ static struct llc_sap_state_trans *llc_sap_active_state_transitions[] = { /* SAP state transition table */ struct llc_sap_state llc_sap_state_table[] = { { - curr_state: LLC_SAP_STATE_INACTIVE, - transitions: llc_sap_inactive_state_transitions, + .curr_state = LLC_SAP_STATE_INACTIVE, + .transitions = llc_sap_inactive_state_transitions, }, { - curr_state: LLC_SAP_STATE_ACTIVE, - transitions: llc_sap_active_state_transitions, + .curr_state = LLC_SAP_STATE_ACTIVE, + .transitions = llc_sap_active_state_transitions, }, }; diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index e35e8e83a094..610d9356f728 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -987,29 +987,29 @@ int netlink_unregister_notifier(struct notifier_block *nb) } struct proto_ops netlink_ops = { - family: PF_NETLINK, - - release: netlink_release, - bind: netlink_bind, - connect: netlink_connect, - socketpair: sock_no_socketpair, - accept: sock_no_accept, - getname: netlink_getname, - poll: datagram_poll, - ioctl: sock_no_ioctl, - listen: sock_no_listen, - shutdown: sock_no_shutdown, - setsockopt: sock_no_setsockopt, - getsockopt: sock_no_getsockopt, - sendmsg: netlink_sendmsg, - recvmsg: netlink_recvmsg, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_NETLINK, + + .release = netlink_release, + .bind = netlink_bind, + .connect = netlink_connect, + .socketpair = sock_no_socketpair, + .accept = sock_no_accept, + .getname = netlink_getname, + .poll = datagram_poll, + .ioctl = sock_no_ioctl, + .listen = sock_no_listen, + .shutdown = sock_no_shutdown, + .setsockopt = sock_no_setsockopt, + .getsockopt = sock_no_getsockopt, + .sendmsg = netlink_sendmsg, + .recvmsg = netlink_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; struct net_proto_family netlink_family_ops = { - family: PF_NETLINK, - create: netlink_create, + .family =PF_NETLINK, + .create =netlink_create, }; static int __init netlink_proto_init(void) diff --git a/net/netlink/netlink_dev.c b/net/netlink/netlink_dev.c index 131209fea01d..e862a2068ee4 100644 --- a/net/netlink/netlink_dev.c +++ b/net/netlink/netlink_dev.c @@ -160,14 +160,14 @@ static int netlink_ioctl(struct inode *inode, struct file *file, static struct file_operations netlink_fops = { - owner: THIS_MODULE, - llseek: no_llseek, - read: netlink_read, - write: netlink_write, - poll: netlink_poll, - ioctl: netlink_ioctl, - open: netlink_open, - release: netlink_release, + .owner = THIS_MODULE, + .llseek = no_llseek, + .read = netlink_read, + .write = netlink_write, + .poll = netlink_poll, + .ioctl = netlink_ioctl, + .open = netlink_open, + .release = netlink_release, }; static devfs_handle_t devfs_handle; diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 36cb8dc0374f..f1dddc7be67b 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -1251,36 +1251,36 @@ static int nr_get_info(char *buffer, char **start, off_t offset, int length) } static struct net_proto_family nr_family_ops = { - family: PF_NETROM, - create: nr_create, + .family = PF_NETROM, + .create = nr_create, }; static struct proto_ops SOCKOPS_WRAPPED(nr_proto_ops) = { - family: PF_NETROM, - - release: nr_release, - bind: nr_bind, - connect: nr_connect, - socketpair: sock_no_socketpair, - accept: nr_accept, - getname: nr_getname, - poll: datagram_poll, - ioctl: nr_ioctl, - listen: nr_listen, - shutdown: sock_no_shutdown, - setsockopt: nr_setsockopt, - getsockopt: nr_getsockopt, - sendmsg: nr_sendmsg, - recvmsg: nr_recvmsg, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_NETROM, + + .release = nr_release, + .bind = nr_bind, + .connect = nr_connect, + .socketpair = sock_no_socketpair, + .accept = nr_accept, + .getname = nr_getname, + .poll = datagram_poll, + .ioctl = nr_ioctl, + .listen = nr_listen, + .shutdown = sock_no_shutdown, + .setsockopt = nr_setsockopt, + .getsockopt = nr_getsockopt, + .sendmsg = nr_sendmsg, + .recvmsg = nr_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; #include <linux/smp_lock.h> SOCKOPS_WRAP(nr_proto, PF_NETROM); static struct notifier_block nr_dev_notifier = { - notifier_call: nr_device_event, + .notifier_call =nr_device_event, }; static struct net_device *dev_nr; diff --git a/net/netsyms.c b/net/netsyms.c index c9a1f1d3eef7..654411e005e0 100644 --- a/net/netsyms.c +++ b/net/netsyms.c @@ -320,6 +320,7 @@ EXPORT_SYMBOL(udp_ioctl); EXPORT_SYMBOL(udp_connect); EXPORT_SYMBOL(udp_disconnect); EXPORT_SYMBOL(udp_sendmsg); +EXPORT_SYMBOL(tcp_bind_hash); EXPORT_SYMBOL(tcp_close); EXPORT_SYMBOL(tcp_disconnect); EXPORT_SYMBOL(tcp_accept); diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 75000d694681..edad9e2f8b7a 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -1609,8 +1609,8 @@ static void packet_mm_close(struct vm_area_struct *vma) } static struct vm_operations_struct packet_mmap_ops = { - open: packet_mm_open, - close: packet_mm_close, + .open = packet_mm_open, + .close =packet_mm_close, }; static void free_pg_vec(unsigned long *pg_vec, unsigned order, unsigned len) @@ -1796,55 +1796,55 @@ out: #ifdef CONFIG_SOCK_PACKET struct proto_ops packet_ops_spkt = { - family: PF_PACKET, - - release: packet_release, - bind: packet_bind_spkt, - connect: sock_no_connect, - socketpair: sock_no_socketpair, - accept: sock_no_accept, - getname: packet_getname_spkt, - poll: datagram_poll, - ioctl: packet_ioctl, - listen: sock_no_listen, - shutdown: sock_no_shutdown, - setsockopt: sock_no_setsockopt, - getsockopt: sock_no_getsockopt, - sendmsg: packet_sendmsg_spkt, - recvmsg: packet_recvmsg, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_PACKET, + + .release = packet_release, + .bind = packet_bind_spkt, + .connect = sock_no_connect, + .socketpair = sock_no_socketpair, + .accept = sock_no_accept, + .getname = packet_getname_spkt, + .poll = datagram_poll, + .ioctl = packet_ioctl, + .listen = sock_no_listen, + .shutdown = sock_no_shutdown, + .setsockopt = sock_no_setsockopt, + .getsockopt = sock_no_getsockopt, + .sendmsg = packet_sendmsg_spkt, + .recvmsg = packet_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; #endif struct proto_ops packet_ops = { - family: PF_PACKET, - - release: packet_release, - bind: packet_bind, - connect: sock_no_connect, - socketpair: sock_no_socketpair, - accept: sock_no_accept, - getname: packet_getname, - poll: packet_poll, - ioctl: packet_ioctl, - listen: sock_no_listen, - shutdown: sock_no_shutdown, - setsockopt: packet_setsockopt, - getsockopt: packet_getsockopt, - sendmsg: packet_sendmsg, - recvmsg: packet_recvmsg, - mmap: packet_mmap, - sendpage: sock_no_sendpage, + .family = PF_PACKET, + + .release = packet_release, + .bind = packet_bind, + .connect = sock_no_connect, + .socketpair = sock_no_socketpair, + .accept = sock_no_accept, + .getname = packet_getname, + .poll = packet_poll, + .ioctl = packet_ioctl, + .listen = sock_no_listen, + .shutdown = sock_no_shutdown, + .setsockopt = packet_setsockopt, + .getsockopt = packet_getsockopt, + .sendmsg = packet_sendmsg, + .recvmsg = packet_recvmsg, + .mmap = packet_mmap, + .sendpage = sock_no_sendpage, }; static struct net_proto_family packet_family_ops = { - family: PF_PACKET, - create: packet_create, + .family = PF_PACKET, + .create = packet_create, }; static struct notifier_block packet_netdev_notifier = { - notifier_call: packet_notifier, + .notifier_call =packet_notifier, }; #ifdef CONFIG_PROC_FS diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index a0c6f8982bc2..f9ccd78a8c0f 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c @@ -1430,36 +1430,36 @@ static int rose_get_info(char *buffer, char **start, off_t offset, int length) } static struct net_proto_family rose_family_ops = { - family: PF_ROSE, - create: rose_create, + .family = PF_ROSE, + .create = rose_create, }; static struct proto_ops SOCKOPS_WRAPPED(rose_proto_ops) = { - family: PF_ROSE, - - release: rose_release, - bind: rose_bind, - connect: rose_connect, - socketpair: sock_no_socketpair, - accept: rose_accept, - getname: rose_getname, - poll: datagram_poll, - ioctl: rose_ioctl, - listen: rose_listen, - shutdown: sock_no_shutdown, - setsockopt: rose_setsockopt, - getsockopt: rose_getsockopt, - sendmsg: rose_sendmsg, - recvmsg: rose_recvmsg, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_ROSE, + + .release = rose_release, + .bind = rose_bind, + .connect = rose_connect, + .socketpair = sock_no_socketpair, + .accept = rose_accept, + .getname = rose_getname, + .poll = datagram_poll, + .ioctl = rose_ioctl, + .listen = rose_listen, + .shutdown = sock_no_shutdown, + .setsockopt = rose_setsockopt, + .getsockopt = rose_getsockopt, + .sendmsg = rose_sendmsg, + .recvmsg = rose_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; #include <linux/smp_lock.h> SOCKOPS_WRAP(rose_proto, PF_ROSE); static struct notifier_block rose_dev_notifier = { - notifier_call: rose_device_event, + .notifier_call =rose_device_event, }; static struct net_device *dev_rose; diff --git a/net/sched/Config.help b/net/sched/Config.help index 47b2e1c2c792..6f281e9f1194 100644 --- a/net/sched/Config.help +++ b/net/sched/Config.help @@ -20,6 +20,20 @@ CONFIG_NET_SCH_CBQ whenever you want). If you want to compile it as a module, say M here and read <file:Documentation/modules.txt>. +CONFIG_NET_SCH_HTB + Say Y here if you want to use the Hierarchical Token Buckets (HTB) + packet scheduling algorithm for some of your network devices. See + URL http://luxik.cdi.cz/~devik/qos/htb/ for complete manual and + in-depth articles. + + HTB is very similar to the CBQ regarding its goals however is has + different properties and different algorithm. + + This code is also available as a module called sch_htb.o ( = code + which can be inserted in and removed from the running kernel + whenever you want). If you want to compile it as a module, say M + here and read <file:Documentation/modules.txt>. + CONFIG_NET_SCH_CSZ Say Y here if you want to use the Clark-Shenker-Zhang (CSZ) packet scheduling algorithm for some of your network devices. At the diff --git a/net/sched/Config.in b/net/sched/Config.in index 566d70d2dc16..8e2034563ccf 100644 --- a/net/sched/Config.in +++ b/net/sched/Config.in @@ -2,6 +2,7 @@ # Traffic control configuration. # tristate ' CBQ packet scheduler' CONFIG_NET_SCH_CBQ +tristate ' HTB packet scheduler' CONFIG_NET_SCH_HTB tristate ' CSZ packet scheduler' CONFIG_NET_SCH_CSZ #tristate ' H-PFQ packet scheduler' CONFIG_NET_SCH_HPFQ #tristate ' H-FSC packet scheduler' CONFIG_NET_SCH_HFCS diff --git a/net/sched/Makefile b/net/sched/Makefile index f08a298192ad..cb07a2aced37 100644 --- a/net/sched/Makefile +++ b/net/sched/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o obj-$(CONFIG_NET_SCH_CSZ) += sch_csz.o obj-$(CONFIG_NET_SCH_HPFQ) += sch_hpfq.o obj-$(CONFIG_NET_SCH_HFSC) += sch_hfsc.o +obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o obj-$(CONFIG_NET_SCH_SFQ) += sch_sfq.o obj-$(CONFIG_NET_SCH_RED) += sch_red.o obj-$(CONFIG_NET_SCH_TBF) += sch_tbf.o diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 4b2917f4084a..a5d8945e4913 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1205,6 +1205,9 @@ int __init pktsched_init(void) #ifdef CONFIG_NET_SCH_CBQ INIT_QDISC(cbq); #endif +#ifdef CONFIG_NET_SCH_HTB + INIT_QDISC(htb); +#endif #ifdef CONFIG_NET_SCH_CSZ INIT_QDISC(csz); #endif diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c new file mode 100644 index 000000000000..ecc1c7c03622 --- /dev/null +++ b/net/sched/sch_htb.c @@ -0,0 +1,1648 @@ +/* vim: ts=8 sw=8 + * net/sched/sch_htb.c Hierarchical token bucket, feed tree version + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Authors: Martin Devera, <devik@cdi.cz> + * + * Credits (in time order) for older HTB versions: + * Ondrej Kraus, <krauso@barr.cz> + * found missing INIT_QDISC(htb) + * Vladimir Smelhaus, Aamer Akhter, Bert Hubert + * helped a lot to locate nasty class stall bug + * Andi Kleen, Jamal Hadi, Bert Hubert + * code review and helpful comments on shaping + * and many others. thanks. + * + * $Id: sch_htb.c,v 1.13 2002/05/25 09:04:50 devik Exp $ + */ +#include <linux/config.h> +#include <linux/module.h> +#include <asm/uaccess.h> +#include <asm/system.h> +#include <asm/bitops.h> +#include <linux/types.h> +#include <linux/kernel.h> +#include <linux/version.h> +#include <linux/sched.h> +#include <linux/string.h> +#include <linux/mm.h> +#include <linux/socket.h> +#include <linux/sockios.h> +#include <linux/in.h> +#include <linux/errno.h> +#include <linux/interrupt.h> +#include <linux/if_ether.h> +#include <linux/inet.h> +#include <linux/netdevice.h> +#include <linux/etherdevice.h> +#include <linux/notifier.h> +#include <net/ip.h> +#include <net/route.h> +#include <linux/skbuff.h> +#include <linux/list.h> +#include <linux/compiler.h> +#include <net/sock.h> +#include <net/pkt_sched.h> +#include <linux/rbtree.h> + +/* HTB algorithm. + Author: devik@cdi.cz + ======================================================================== + HTB is like TBF with multiple classes. It is also similar to CBQ because + it allows to assign priority to each class in hierarchy. + In fact it is another implementation of Floyd's formal sharing. + + Levels: + Each class is assigned level. Leaf has ALWAYS level 0 and root + classes have level TC_HTB_MAXDEPTH-1. Interior nodes has level + one less than their parent. +*/ + +#define HTB_HSIZE 16 /* classid hash size */ +#define HTB_EWMAC 2 /* rate average over HTB_EWMAC*HTB_HSIZE sec */ +#define HTB_DEBUG 1 /* compile debugging support (activated by tc tool) */ +#define HTB_RATECM 1 /* whether to use rate computer */ +#define HTB_HYSTERESIS 1/* whether to use mode hysteresis for speedup */ +#define HTB_QLOCK(S) spin_lock_bh(&(S)->dev->queue_lock) +#define HTB_QUNLOCK(S) spin_unlock_bh(&(S)->dev->queue_lock) +#define HTB_VER 0x30006 /* major must be matched with number suplied by TC as version */ + +#if HTB_VER >> 16 != TC_HTB_PROTOVER +#error "Mismatched sch_htb.c and pkt_sch.h" +#endif + +/* temporary debug defines to be removed after beta stage */ +#define DEVIK_MEND(N) +#define DEVIK_MSTART(N) + +/* debugging support; S is subsystem, these are defined: + 0 - netlink messages + 1 - enqueue + 2 - drop & requeue + 3 - dequeue main + 4 - dequeue one prio DRR part + 5 - dequeue class accounting + 6 - class overlimit status computation + 7 - hint tree + 8 - event queue + 10 - rate estimator + 11 - classifier + 12 - fast dequeue cache + + L is level; 0 = none, 1 = basic info, 2 = detailed, 3 = full + q->debug uint32 contains 16 2-bit fields one for subsystem starting + from LSB + */ +#ifdef HTB_DEBUG +#define HTB_DBG(S,L,FMT,ARG...) if (((q->debug>>(2*S))&3) >= L) \ + printk(KERN_DEBUG FMT,##ARG) +#define HTB_CHCL(cl) BUG_TRAP((cl)->magic == HTB_CMAGIC) +#define HTB_PASSQ q, +#define HTB_ARGQ struct htb_sched *q, +#define static +#define __inline__ +#define inline +#define HTB_CMAGIC 0xFEFAFEF1 +#define htb_safe_rb_erase(N,R) do { BUG_TRAP((N)->rb_color != -1); \ + if ((N)->rb_color == -1) break; \ + rb_erase(N,R); \ + (N)->rb_color = -1; } while (0) +#else +#define HTB_DBG(S,L,FMT,ARG...) +#define HTB_PASSQ +#define HTB_ARGQ +#define HTB_CHCL(cl) +#define htb_safe_rb_erase(N,R) rb_erase(N,R) +#endif + + +/* used internaly to keep status of single class */ +enum htb_cmode { + HTB_CANT_SEND, /* class can't send and can't borrow */ + HTB_MAY_BORROW, /* class can't send but may borrow */ + HTB_CAN_SEND /* class can send */ +}; + +/* interior & leaf nodes; props specific to leaves are marked L: */ +struct htb_class +{ +#ifdef HTB_DEBUG + unsigned magic; +#endif + /* general class parameters */ + u32 classid; + struct tc_stats stats; /* generic stats */ + struct tc_htb_xstats xstats;/* our special stats */ + int refcnt; /* usage count of this class */ + +#ifdef HTB_RATECM + /* rate measurement counters */ + unsigned long rate_bytes,sum_bytes; + unsigned long rate_packets,sum_packets; +#endif + + /* topology */ + int level; /* our level (see above) */ + struct htb_class *parent; /* parent class */ + struct list_head hlist; /* classid hash list item */ + struct list_head sibling; /* sibling list item */ + struct list_head children; /* children list */ + + union { + struct htb_class_leaf { + struct Qdisc *q; + int prio; + int aprio; + int quantum; + int deficit[TC_HTB_MAXDEPTH]; + struct list_head drop_list; + } leaf; + struct htb_class_inner { + rb_root_t feed[TC_HTB_NUMPRIO]; /* feed trees */ + rb_node_t *ptr[TC_HTB_NUMPRIO]; /* current class ptr */ + } inner; + } un; + rb_node_t node[TC_HTB_NUMPRIO]; /* node for self or feed tree */ + rb_node_t pq_node; /* node for event queue */ + unsigned long pq_key; /* the same type as jiffies global */ + + int prio_activity; /* for which prios are we active */ + enum htb_cmode cmode; /* current mode of the class */ + + /* class attached filters */ + struct tcf_proto *filter_list; + int filter_cnt; + + int warned; /* only one warning about non work conserving .. */ + + /* token bucket parameters */ + struct qdisc_rate_table *rate; /* rate table of the class itself */ + struct qdisc_rate_table *ceil; /* ceiling rate (limits borrows too) */ + long buffer,cbuffer; /* token bucket depth/rate */ + long mbuffer; /* max wait time */ + long tokens,ctokens; /* current number of tokens */ + psched_time_t t_c; /* checkpoint time */ +}; + +/* TODO: maybe compute rate when size is too large .. or drop ? */ +static __inline__ long L2T(struct htb_class *cl,struct qdisc_rate_table *rate, + int size) +{ + int slot = size >> rate->rate.cell_log; + if (slot > 255) { + cl->xstats.giants++; + slot = 255; + } + return rate->data[slot]; +} + +struct htb_sched +{ + struct list_head root; /* root classes list */ + struct list_head hash[HTB_HSIZE]; /* hashed by classid */ + struct list_head drops[TC_HTB_NUMPRIO]; /* active leaves (for drops) */ + + /* self list - roots of self generating tree */ + rb_root_t row[TC_HTB_MAXDEPTH][TC_HTB_NUMPRIO]; + int row_mask[TC_HTB_MAXDEPTH]; + rb_node_t *ptr[TC_HTB_MAXDEPTH][TC_HTB_NUMPRIO]; + + /* self wait list - roots of wait PQs per row */ + rb_root_t wait_pq[TC_HTB_MAXDEPTH]; + + /* time of nearest event per level (row) */ + unsigned long near_ev_cache[TC_HTB_MAXDEPTH]; + + /* whether we hit non-work conserving class during this dequeue; we use */ + int nwc_hit; /* this to disable mindelay complaint in dequeue */ + + int defcls; /* class where unclassified flows go to */ + u32 debug; /* subsystem debug levels */ + + /* filters for qdisc itself */ + struct tcf_proto *filter_list; + int filter_cnt; + + int rate2quantum; /* quant = rate / rate2quantum */ + psched_time_t now; /* cached dequeue time */ + struct timer_list timer; /* send delay timer */ +#ifdef HTB_RATECM + struct timer_list rttim; /* rate computer timer */ + int recmp_bucket; /* which hash bucket to recompute next */ +#endif + + /* non shaped skbs; let them go directly thru */ + struct sk_buff_head direct_queue; + int direct_qlen; /* max qlen of above */ + + long direct_pkts; +}; + +/* compute hash of size HTB_HSIZE for given handle */ +static __inline__ int htb_hash(u32 h) +{ +#if HTB_HSIZE != 16 + #error "Declare new hash for your HTB_HSIZE" +#endif + h ^= h>>8; /* stolen from cbq_hash */ + h ^= h>>4; + return h & 0xf; +} + +/* find class in global hash table using given handle */ +static __inline__ struct htb_class *htb_find(u32 handle, struct Qdisc *sch) +{ + struct htb_sched *q = (struct htb_sched *)sch->data; + struct list_head *p; + if (TC_H_MAJ(handle) != sch->handle) + return NULL; + + list_for_each (p,q->hash+htb_hash(handle)) { + struct htb_class *cl = list_entry(p,struct htb_class,hlist); + if (cl->classid == handle) + return cl; + } + return NULL; +} + +/** + * htb_classify - classify a packet into class + * + * It returns NULL if the packet should be dropped or -1 if the packet + * should be passed directly thru. In all other cases leaf class is returned. + * We allow direct class selection by classid in priority. The we examine + * filters in qdisc and in inner nodes (if higher filter points to the inner + * node). If we end up with classid MAJOR:0 we enqueue the skb into special + * internal fifo (direct). These packets then go directly thru. If we still + * have no valid leaf we try to use MAJOR:default leaf. It still unsuccessfull + * then finish and return direct queue. + */ +#define HTB_DIRECT (struct htb_class*)-1 +static struct htb_class *htb_classify(struct sk_buff *skb, struct Qdisc *sch) +{ + struct htb_sched *q = (struct htb_sched *)sch->data; + struct htb_class *cl; + struct tcf_result res; + struct tcf_proto *tcf; + int result; + + /* allow to select class by setting skb->priority to valid classid; + note that nfmark can be used too by attaching filter fw with no + rules in it */ + if (skb->priority == sch->handle) + return HTB_DIRECT; /* X:0 (direct flow) selected */ + if ((cl = htb_find(skb->priority,sch)) != NULL) + return cl; + + tcf = q->filter_list; + while (tcf && (result = tc_classify(skb, tcf, &res)) >= 0) { +#ifdef CONFIG_NET_CLS_POLICE + if (result == TC_POLICE_SHOT) + return NULL; +#endif + if ((cl = (void*)res.class) == NULL) { + if (res.classid == sch->handle) + return HTB_DIRECT; /* X:0 (direct flow) */ + if ((cl = htb_find(res.classid,sch)) == NULL) + break; /* filter selected invalid classid */ + } + if (!cl->level) + return cl; /* we hit leaf; return it */ + + /* we have got inner class; apply inner filter chain */ + tcf = cl->filter_list; + } + /* classification failed; try to use default class */ + cl = htb_find(TC_H_MAKE(TC_H_MAJ(sch->handle),q->defcls),sch); + if (!cl || cl->level) + return HTB_DIRECT; /* bad default .. this is safe bet */ + return cl; +} + +#ifdef HTB_DEBUG +static void htb_next_rb_node(rb_node_t **n); +#define HTB_DUMTREE(root,memb) if(root) { \ + rb_node_t *n = (root)->rb_node; \ + while (n->rb_left) n = n->rb_left; \ + while (n) { \ + struct htb_class *cl = rb_entry(n, struct htb_class, memb); \ + printk(" %x",cl->classid); htb_next_rb_node (&n); \ + } } + +static void htb_debug_dump (struct htb_sched *q) +{ + int i,p; + printk(KERN_DEBUG "htb*g j=%lu\n",jiffies); + /* rows */ + for (i=TC_HTB_MAXDEPTH-1;i>=0;i--) { + printk(KERN_DEBUG "htb*r%d m=%x",i,q->row_mask[i]); + for (p=0;p<TC_HTB_NUMPRIO;p++) { + if (!q->row[i][p].rb_node) continue; + printk(" p%d:",p); + HTB_DUMTREE(q->row[i]+p,node[p]); + } + printk("\n"); + } + /* classes */ + for (i = 0; i < HTB_HSIZE; i++) { + struct list_head *l; + list_for_each (l,q->hash+i) { + struct htb_class *cl = list_entry(l,struct htb_class,hlist); + long diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer, 0); + printk(KERN_DEBUG "htb*c%x m=%d t=%ld c=%ld pq=%lu df=%ld ql=%d " + "pa=%x f:", + cl->classid,cl->cmode,cl->tokens,cl->ctokens, + cl->pq_node.rb_color==-1?0:cl->pq_key,diff, + cl->level?0:cl->un.leaf.q->q.qlen,cl->prio_activity); + if (cl->level) + for (p=0;p<TC_HTB_NUMPRIO;p++) { + if (!cl->un.inner.feed[p].rb_node) continue; + printk(" p%d a=%x:",p,cl->un.inner.ptr[p]?rb_entry(cl->un.inner.ptr[p], struct htb_class,node[p])->classid:0); + HTB_DUMTREE(cl->un.inner.feed+p,node[p]); + } + printk("\n"); + } + } +} +#endif +/** + * htb_add_to_id_tree - adds class to the round robin list + * + * Routine adds class to the list (actually tree) sorted by classid. + * Make sure that class is not already on such list for given prio. + */ +static void htb_add_to_id_tree (HTB_ARGQ rb_root_t *root, + struct htb_class *cl,int prio) +{ + rb_node_t **p = &root->rb_node, *parent = NULL; + HTB_DBG(7,3,"htb_add_id_tree cl=%X prio=%d\n",cl->classid,prio); +#ifdef HTB_DEBUG + if (cl->node[prio].rb_color != -1) { BUG_TRAP(0); return; } + HTB_CHCL(cl); + if (*p) { + struct htb_class *x = rb_entry(*p,struct htb_class,node[prio]); + HTB_CHCL(x); + } +#endif + while (*p) { + struct htb_class *c; parent = *p; + c = rb_entry(parent, struct htb_class, node[prio]); + HTB_CHCL(c); + if (cl->classid > c->classid) + p = &parent->rb_right; + else + p = &parent->rb_left; + } + rb_link_node(&cl->node[prio], parent, p); + rb_insert_color(&cl->node[prio], root); +} + +/** + * htb_add_to_wait_tree - adds class to the event queue with delay + * + * The class is added to priority event queue to indicate that class will + * change its mode in cl->pq_key microseconds. Make sure that class is not + * already in the queue. + */ +static void htb_add_to_wait_tree (struct htb_sched *q, + struct htb_class *cl,long delay,int debug_hint) +{ + rb_node_t **p = &q->wait_pq[cl->level].rb_node, *parent = NULL; + HTB_DBG(7,3,"htb_add_wt cl=%X key=%lu\n",cl->classid,cl->pq_key); +#ifdef HTB_DEBUG + if (cl->pq_node.rb_color != -1) { BUG_TRAP(0); return; } + HTB_CHCL(cl); + if ((delay <= 0 || delay > cl->mbuffer) && net_ratelimit()) + printk(KERN_ERR "HTB: suspicious delay in wait_tree d=%ld cl=%X h=%d\n",delay,cl->classid,debug_hint); +#endif + DEVIK_MSTART(9); + cl->pq_key = jiffies + PSCHED_US2JIFFIE(delay); + if (cl->pq_key == jiffies) + cl->pq_key++; + + /* update the nearest event cache */ + if (q->near_ev_cache[cl->level] - cl->pq_key < 0x80000000) + q->near_ev_cache[cl->level] = cl->pq_key; + + while (*p) { + struct htb_class *c; parent = *p; + c = rb_entry(parent, struct htb_class, pq_node); + if (cl->pq_key - c->pq_key < 0x80000000) + p = &parent->rb_right; + else + p = &parent->rb_left; + } + rb_link_node(&cl->pq_node, parent, p); + rb_insert_color(&cl->pq_node, &q->wait_pq[cl->level]); + DEVIK_MEND(9); +} + +/** + * htb_next_rb_node - finds next node in binary tree + * + * When we are past last key we return NULL. + * Average complexity is 2 steps per call. + */ +static void htb_next_rb_node(rb_node_t **n) +{ + rb_node_t *p; + if ((*n)->rb_right) { + *n = (*n)->rb_right; + while ((*n)->rb_left) + *n = (*n)->rb_left; + return; + } + while ((p = (*n)->rb_parent) != NULL) { + if (p->rb_left == *n) break; + *n = p; + } + *n = p; +} + +/** + * htb_add_class_to_row - add class to its row + * + * The class is added to row at priorities marked in mask. + * It does nothing if mask == 0. + */ +static inline void htb_add_class_to_row(struct htb_sched *q, + struct htb_class *cl,int mask) +{ + HTB_DBG(7,2,"htb_addrow cl=%X mask=%X rmask=%X\n", + cl->classid,mask,q->row_mask[cl->level]); + HTB_CHCL(cl); + q->row_mask[cl->level] |= mask; + while (mask) { + int prio = ffz(~mask); + mask &= ~(1 << prio); + htb_add_to_id_tree(HTB_PASSQ q->row[cl->level]+prio,cl,prio); + } +} + +/** + * htb_remove_class_from_row - removes class from its row + * + * The class is removed from row at priorities marked in mask. + * It does nothing if mask == 0. + */ +static __inline__ void htb_remove_class_from_row(struct htb_sched *q, + struct htb_class *cl,int mask) +{ + int m = 0; + HTB_CHCL(cl); + while (mask) { + int prio = ffz(~mask); + mask &= ~(1 << prio); + if (q->ptr[cl->level][prio] == cl->node+prio) + htb_next_rb_node(q->ptr[cl->level]+prio); + htb_safe_rb_erase(cl->node + prio,q->row[cl->level]+prio); + if (!q->row[cl->level][prio].rb_node) + m |= 1 << prio; + } + HTB_DBG(7,2,"htb_delrow cl=%X mask=%X rmask=%X maskdel=%X\n", + cl->classid,mask,q->row_mask[cl->level],m); + q->row_mask[cl->level] &= ~m; +} + +/** + * htb_activate_prios - creates active classe's feed chain + * + * The class is connected to ancestors and/or appropriate rows + * for priorities it is participating on. cl->cmode must be new + * (activated) mode. It does nothing if cl->prio_activity == 0. + */ +static void htb_activate_prios(struct htb_sched *q,struct htb_class *cl) +{ + struct htb_class *p = cl->parent; + long m,mask = cl->prio_activity; + HTB_DBG(7,2,"htb_act_prios cl=%X mask=%lX cmode=%d\n",cl->classid,mask,cl->cmode); + HTB_CHCL(cl); + + while (cl->cmode == HTB_MAY_BORROW && p && mask) { + HTB_CHCL(p); + m = mask; while (m) { + int prio = ffz(~m); + m &= ~(1 << prio); + + if (p->un.inner.feed[prio].rb_node) + /* parent already has its feed in use so that + reset bit in mask as parent is already ok */ + mask &= ~(1 << prio); + + htb_add_to_id_tree(HTB_PASSQ p->un.inner.feed+prio,cl,prio); + } + HTB_DBG(7,3,"htb_act_pr_aft p=%X pact=%X mask=%lX pmode=%d\n", + p->classid,p->prio_activity,mask,p->cmode); + p->prio_activity |= mask; + cl = p; p = cl->parent; + HTB_CHCL(cl); + } + if (cl->cmode == HTB_CAN_SEND && mask) + htb_add_class_to_row(q,cl,mask); +} + +/** + * htb_deactivate_prios - remove class from feed chain + * + * cl->cmode must represent old mode (before deactivation). It does + * nothing if cl->prio_activity == 0. Class is removed from all feed + * chains and rows. + */ +static void htb_deactivate_prios(struct htb_sched *q, struct htb_class *cl) +{ + struct htb_class *p = cl->parent; + long m,mask = cl->prio_activity; + HTB_DBG(7,2,"htb_deact_prios cl=%X mask=%lX cmode=%d\n",cl->classid,mask,cl->cmode); + HTB_CHCL(cl); + + while (cl->cmode == HTB_MAY_BORROW && p && mask) { + m = mask; mask = 0; + while (m) { + int prio = ffz(~m); + m &= ~(1 << prio); + + if (p->un.inner.ptr[prio] == cl->node+prio) + htb_next_rb_node(p->un.inner.ptr + prio); + + htb_safe_rb_erase(cl->node + prio,p->un.inner.feed + prio); + + if (!p->un.inner.feed[prio].rb_node) + mask |= 1 << prio; + } + HTB_DBG(7,3,"htb_deact_pr_aft p=%X pact=%X mask=%lX pmode=%d\n", + p->classid,p->prio_activity,mask,p->cmode); + p->prio_activity &= ~mask; + cl = p; p = cl->parent; + HTB_CHCL(cl); + } + if (cl->cmode == HTB_CAN_SEND && mask) + htb_remove_class_from_row(q,cl,mask); +} + +/** + * htb_class_mode - computes and returns current class mode + * + * It computes cl's mode at time cl->t_c+diff and returns it. If mode + * is not HTB_CAN_SEND then cl->pq_key is updated to time difference + * from now to time when cl will change its state. + * Also it is worth to note that class mode doesn't change simply + * at cl->{c,}tokens == 0 but there can rather be hysteresis of + * 0 .. -cl->{c,}buffer range. It is meant to limit number of + * mode transitions per time unit. The speed gain is about 1/6. + */ +static __inline__ enum htb_cmode +htb_class_mode(struct htb_class *cl,long *diff) +{ + long toks; + + if ((toks = (cl->ctokens + *diff)) < ( +#ifdef HTB_HYSTERESIS + cl->cmode != HTB_CANT_SEND ? -cl->cbuffer : +#endif + 0)) { + *diff = -toks; + return HTB_CANT_SEND; + } + if ((toks = (cl->tokens + *diff)) >= ( +#ifdef HTB_HYSTERESIS + cl->cmode == HTB_CAN_SEND ? -cl->buffer : +#endif + 0)) + return HTB_CAN_SEND; + + *diff = -toks; + return HTB_MAY_BORROW; +} + +/** + * htb_change_class_mode - changes classe's mode + * + * This should be the only way how to change classe's mode under normal + * cirsumstances. Routine will update feed lists linkage, change mode + * and add class to the wait event queue if appropriate. New mode should + * be different from old one and cl->pq_key has to be valid if changing + * to mode other than HTB_CAN_SEND (see htb_add_to_wait_tree). + */ +static void +htb_change_class_mode(struct htb_sched *q, struct htb_class *cl, long *diff) +{ + enum htb_cmode new_mode = htb_class_mode(cl,diff); + + HTB_CHCL(cl); + HTB_DBG(7,1,"htb_chging_clmode %d->%d cl=%X\n",cl->cmode,new_mode,cl->classid); + + if (new_mode == cl->cmode) + return; + + if (cl->prio_activity) { /* not neccessary: speed optimization */ + if (cl->cmode != HTB_CANT_SEND) + htb_deactivate_prios(q,cl); + cl->cmode = new_mode; + if (new_mode != HTB_CANT_SEND) + htb_activate_prios(q,cl); + } else + cl->cmode = new_mode; +} + +/** + * htb_activate - inserts leaf cl into appropriate active feeds + * + * Routine learns (new) priority of leaf and activates feed chain + * for the prio. It can be called on already active leaf safely. + * It also adds leaf into droplist. + */ +static __inline__ void htb_activate(struct htb_sched *q,struct htb_class *cl) +{ + BUG_TRAP(!cl->level && cl->un.leaf.q && cl->un.leaf.q->q.qlen); + HTB_CHCL(cl); + if (!cl->prio_activity) { + cl->prio_activity = 1 << (cl->un.leaf.aprio = cl->un.leaf.prio); + htb_activate_prios(q,cl); + list_add_tail(&cl->un.leaf.drop_list,q->drops+cl->un.leaf.aprio); + } +} + +/** + * htb_deactivate - remove leaf cl from active feeds + * + * Make sure that leaf is active. In the other words it can't be called + * with non-active leaf. It also removes class from the drop list. + */ +static __inline__ void +htb_deactivate(struct htb_sched *q,struct htb_class *cl) +{ + BUG_TRAP(cl->prio_activity); + HTB_CHCL(cl); + htb_deactivate_prios(q,cl); + cl->prio_activity = 0; + list_del_init(&cl->un.leaf.drop_list); +} + +static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch) +{ + struct htb_sched *q = (struct htb_sched *)sch->data; + struct htb_class *cl = htb_classify(skb,sch); + + DEVIK_MSTART(0); + if (cl == HTB_DIRECT || !cl) { + /* enqueue to helper queue */ + if (q->direct_queue.qlen < q->direct_qlen && cl) { + __skb_queue_tail(&q->direct_queue, skb); + q->direct_pkts++; + } else { + kfree_skb (skb); + sch->stats.drops++; + DEVIK_MEND(0); + return NET_XMIT_DROP; + } + } else if (cl->un.leaf.q->enqueue(skb, cl->un.leaf.q) != NET_XMIT_SUCCESS) { + sch->stats.drops++; + cl->stats.drops++; + DEVIK_MEND(0); + return NET_XMIT_DROP; + } else { + cl->stats.packets++; cl->stats.bytes += skb->len; + DEVIK_MSTART(1); + htb_activate (q,cl); + DEVIK_MEND(1); + } + + sch->q.qlen++; + sch->stats.packets++; sch->stats.bytes += skb->len; + HTB_DBG(1,1,"htb_enq_ok cl=%X skb=%p\n",cl?cl->classid:0,skb); + DEVIK_MEND(0); + return NET_XMIT_SUCCESS; +} + +/* TODO: requeuing packet charges it to policers again !! */ +static int htb_requeue(struct sk_buff *skb, struct Qdisc *sch) +{ + struct htb_sched *q = (struct htb_sched *)sch->data; + struct htb_class *cl = htb_classify(skb,sch); + + if (cl == HTB_DIRECT || !cl) { + /* enqueue to helper queue */ + if (q->direct_queue.qlen < q->direct_qlen && cl) { + __skb_queue_tail(&q->direct_queue, skb); + q->direct_pkts++; + } else { + kfree_skb (skb); + sch->stats.drops++; + return NET_XMIT_DROP; + } + } else if (cl->un.leaf.q->ops->requeue(skb, cl->un.leaf.q) != NET_XMIT_SUCCESS) { + sch->stats.drops++; + cl->stats.drops++; + return NET_XMIT_DROP; + } else + htb_activate (q,cl); + + sch->q.qlen++; + HTB_DBG(1,1,"htb_req_ok cl=%X skb=%p\n",cl?cl->classid:0,skb); + return NET_XMIT_SUCCESS; +} + +static void htb_timer(unsigned long arg) +{ + struct Qdisc *sch = (struct Qdisc*)arg; + sch->flags &= ~TCQ_F_THROTTLED; + wmb(); + netif_schedule(sch->dev); +} + +#ifdef HTB_RATECM +#define RT_GEN(D,R) R+=D-(R/HTB_EWMAC);D=0 +static void htb_rate_timer(unsigned long arg) +{ + struct Qdisc *sch = (struct Qdisc*)arg; + struct htb_sched *q = (struct htb_sched *)sch->data; + struct list_head *p; + + /* lock queue so that we can muck with it */ + HTB_QLOCK(sch); + HTB_DBG(10,1,"htb_rttmr j=%ld\n",jiffies); + + q->rttim.expires = jiffies + HZ; + add_timer(&q->rttim); + + /* scan and recompute one bucket at time */ + if (++q->recmp_bucket >= HTB_HSIZE) + q->recmp_bucket = 0; + list_for_each (p,q->hash+q->recmp_bucket) { + struct htb_class *cl = list_entry(p,struct htb_class,hlist); + HTB_DBG(10,2,"htb_rttmr_cl cl=%X sbyte=%lu spkt=%lu\n", + cl->classid,cl->sum_bytes,cl->sum_packets); + RT_GEN (cl->sum_bytes,cl->rate_bytes); + RT_GEN (cl->sum_packets,cl->rate_packets); + } + HTB_QUNLOCK(sch); +} +#endif + +/** + * htb_charge_class - charges ammount "bytes" to leaf and ancestors + * + * Routine assumes that packet "bytes" long was dequeued from leaf cl + * borrowing from "level". It accounts bytes to ceil leaky bucket for + * leaf and all ancestors and to rate bucket for ancestors at levels + * "level" and higher. It also handles possible change of mode resulting + * from the update. Note that mode can also increase here (MAY_BORROW to + * CAN_SEND) because we can use more precise clock that event queue here. + * In such case we remove class from event queue first. + */ +static void htb_charge_class(struct htb_sched *q,struct htb_class *cl, + int level,int bytes) +{ + long toks,diff; + enum htb_cmode old_mode; + HTB_DBG(5,1,"htb_chrg_cl cl=%X lev=%d len=%d\n",cl->classid,level,bytes); + +#define HTB_ACCNT(T,B,R) toks = diff + cl->T; \ + if (toks > cl->B) toks = cl->B; \ + toks -= L2T(cl, cl->R, bytes); \ + if (toks <= -cl->mbuffer) toks = 1-cl->mbuffer; \ + cl->T = toks + + while (cl) { + HTB_CHCL(cl); + diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer, 0); +#ifdef HTB_DEBUG + if (diff > cl->mbuffer || diff < 0 || PSCHED_TLESS(q->now, cl->t_c)) { + if (net_ratelimit()) + printk(KERN_ERR "HTB: bad diff in charge, cl=%X diff=%lX now=%Lu then=%Lu j=%lu\n", + cl->classid, diff, + (unsigned long long) q->now, + (unsigned long long) cl->t_c, + jiffies); + diff = 1000; + } +#endif + if (cl->level >= level) { + if (cl->level == level) cl->xstats.lends++; + HTB_ACCNT (tokens,buffer,rate); + } else { + cl->xstats.borrows++; + cl->tokens += diff; /* we moved t_c; update tokens */ + } + HTB_ACCNT (ctokens,cbuffer,ceil); + cl->t_c = q->now; + HTB_DBG(5,2,"htb_chrg_clp cl=%X diff=%ld tok=%ld ctok=%ld\n",cl->classid,diff,cl->tokens,cl->ctokens); + + old_mode = cl->cmode; diff = 0; + htb_change_class_mode(q,cl,&diff); + if (old_mode != cl->cmode) { + if (old_mode != HTB_CAN_SEND) + htb_safe_rb_erase(&cl->pq_node,q->wait_pq+cl->level); + if (cl->cmode != HTB_CAN_SEND) + htb_add_to_wait_tree (q,cl,diff,1); + } + +#ifdef HTB_RATECM + /* update rate counters */ + cl->sum_bytes += bytes; cl->sum_packets++; +#endif + + /* update byte stats except for leaves which are already updated */ + if (cl->level) { + cl->stats.bytes += bytes; + cl->stats.packets++; + } + cl = cl->parent; + } +} + +/** + * htb_do_events - make mode changes to classes at the level + * + * Scans event queue for pending events and applies them. Returns jiffies to + * next pending event (0 for no event in pq). + */ +static long htb_do_events(struct htb_sched *q,int level) +{ + int i; + HTB_DBG(8,1,"htb_do_events l=%d root=%p rmask=%X\n", + level,q->wait_pq[level].rb_node,q->row_mask[level]); + for (i = 0; i < 500; i++) { + struct htb_class *cl; + long diff; + rb_node_t *p = q->wait_pq[level].rb_node; + if (!p) return 0; + while (p->rb_left) p = p->rb_left; + + cl = rb_entry(p, struct htb_class, pq_node); + if (cl->pq_key - (jiffies+1) < 0x80000000) { + HTB_DBG(8,3,"htb_do_ev_ret delay=%ld\n",cl->pq_key - jiffies); + return cl->pq_key - jiffies; + } + htb_safe_rb_erase(p,q->wait_pq+level); + diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer, 0); +#ifdef HTB_DEBUG + if (diff > cl->mbuffer || diff < 0 || PSCHED_TLESS(q->now, cl->t_c)) { + if (net_ratelimit()) + printk(KERN_ERR "HTB: bad diff in events, cl=%X diff=%lX now=%Lu then=%Lu j=%lu\n", + cl->classid, diff, + (unsigned long long) q->now, + (unsigned long long) cl->t_c, + jiffies); + diff = 1000; + } +#endif + htb_change_class_mode(q,cl,&diff); + if (cl->cmode != HTB_CAN_SEND) + htb_add_to_wait_tree (q,cl,diff,2); + } + if (net_ratelimit()) + printk(KERN_WARNING "htb: too many events !\n"); + return HZ/10; +} + +/** + * htb_lookup_leaf - returns next leaf class in DRR order + * + * Find leaf where current feed pointers points to. + */ +static struct htb_class * +htb_lookup_leaf(rb_root_t *tree,int prio,rb_node_t **pptr) +{ + int i; + struct { + rb_node_t *root; + rb_node_t **pptr; + } stk[TC_HTB_MAXDEPTH],*sp = stk; + + sp->root = tree->rb_node; + sp->pptr = pptr; + + for (i = 0; i < 65535; i++) { + if (!*sp->pptr) { /* we are at right end; rewind & go up */ + *sp->pptr = sp->root; + while ((*sp->pptr)->rb_left) + *sp->pptr = (*sp->pptr)->rb_left; + if (sp > stk) { + sp--; + BUG_TRAP(*sp->pptr); if(!*sp->pptr) return NULL; + htb_next_rb_node (sp->pptr); + } + } else { + struct htb_class *cl; + cl = rb_entry(*sp->pptr,struct htb_class,node[prio]); + HTB_CHCL(cl); + if (!cl->level) + return cl; + (++sp)->root = cl->un.inner.feed[prio].rb_node; + sp->pptr = cl->un.inner.ptr+prio; + } + } + BUG_TRAP(0); + return NULL; +} + +/* dequeues packet at given priority and level; call only if + you are sure that there is active class at prio/level */ +static struct sk_buff * +htb_dequeue_tree(struct htb_sched *q,int prio,int level) +{ + struct sk_buff *skb = NULL; + //struct htb_sched *q = (struct htb_sched *)sch->data; + struct htb_class *cl,*start; + /* look initial class up in the row */ + DEVIK_MSTART(6); + start = cl = htb_lookup_leaf (q->row[level]+prio,prio,q->ptr[level]+prio); + + do { + BUG_TRAP(cl && cl->un.leaf.q->q.qlen); if (!cl) return NULL; + HTB_DBG(4,1,"htb_deq_tr prio=%d lev=%d cl=%X defic=%d\n", + prio,level,cl->classid,cl->un.leaf.deficit[level]); + + if (likely((skb = cl->un.leaf.q->dequeue(cl->un.leaf.q)) != NULL)) + break; + if (!cl->warned) { + printk(KERN_WARNING "htb: class %X isn't work conserving ?!\n",cl->classid); + cl->warned = 1; + } + q->nwc_hit++; + htb_next_rb_node((level?cl->parent->un.inner.ptr:q->ptr[0])+prio); + cl = htb_lookup_leaf (q->row[level]+prio,prio,q->ptr[level]+prio); + } while (cl != start); + + DEVIK_MEND(6); + DEVIK_MSTART(7); + if (likely(skb != NULL)) { + if ((cl->un.leaf.deficit[level] -= skb->len) < 0) { + HTB_DBG(4,2,"htb_next_cl oldptr=%p quant_add=%d\n", + level?cl->parent->un.inner.ptr[prio]:q->ptr[0][prio],cl->un.leaf.quantum); + cl->un.leaf.deficit[level] += cl->un.leaf.quantum; + htb_next_rb_node((level?cl->parent->un.inner.ptr:q->ptr[0])+prio); + } + /* this used to be after charge_class but this constelation + gives us slightly better performance */ + if (!cl->un.leaf.q->q.qlen) + htb_deactivate (q,cl); + DEVIK_MSTART(8); + htb_charge_class (q,cl,level,skb->len); + DEVIK_MEND(8); + } + DEVIK_MEND(7); + return skb; +} + +static void htb_delay_by(struct Qdisc *sch,long delay) +{ + struct htb_sched *q = (struct htb_sched *)sch->data; + if (netif_queue_stopped(sch->dev)) return; + if (delay <= 0) delay = 1; + if (unlikely(delay > 5*HZ)) { + if (net_ratelimit()) + printk(KERN_INFO "HTB delay %ld > 5sec\n", delay); + delay = 5*HZ; + } + del_timer(&q->timer); + q->timer.expires = jiffies + delay; + add_timer(&q->timer); + sch->flags |= TCQ_F_THROTTLED; + sch->stats.overlimits++; + HTB_DBG(3,1,"htb_deq t_delay=%ld\n",delay); +} + +static struct sk_buff *htb_dequeue(struct Qdisc *sch) +{ + struct sk_buff *skb = NULL; + struct htb_sched *q = (struct htb_sched *)sch->data; + int level; + long min_delay; + + HTB_DBG(3,1,"htb_deq dircnt=%d qlen=%d\n",skb_queue_len(&q->direct_queue), + sch->q.qlen); + + /* try to dequeue direct packets as high prio (!) to minimize cpu work */ + if ((skb = __skb_dequeue(&q->direct_queue)) != NULL) { + sch->flags &= ~TCQ_F_THROTTLED; + sch->q.qlen--; + return skb; + } + + DEVIK_MSTART(2); + if (!sch->q.qlen) goto fin; + PSCHED_GET_TIME(q->now); + + min_delay = HZ*5; + q->nwc_hit = 0; + for (level = 0; level < TC_HTB_MAXDEPTH; level++) { + /* common case optimization - skip event handler quickly */ + int m; + long delay; + DEVIK_MSTART(3); + if (jiffies - q->near_ev_cache[level] < 0x80000000 || 0) { + delay = htb_do_events(q,level); + q->near_ev_cache[level] += delay ? delay : HZ; + } else + delay = q->near_ev_cache[level] - jiffies; + + if (delay && min_delay > delay) + min_delay = delay; + DEVIK_MEND(3); + DEVIK_MSTART(5); + m = ~q->row_mask[level]; + while (m != (int)(-1)) { + int prio = ffz (m); + m |= 1 << prio; + skb = htb_dequeue_tree(q,prio,level); + if (likely(skb != NULL)) { + sch->q.qlen--; + sch->flags &= ~TCQ_F_THROTTLED; + DEVIK_MEND(5); + goto fin; + } + } + DEVIK_MEND(5); + } + DEVIK_MSTART(4); +#ifdef HTB_DEBUG + if (!q->nwc_hit && min_delay >= 5*HZ && net_ratelimit()) { + printk(KERN_ERR "HTB: mindelay=%ld, report it please !\n",min_delay); + htb_debug_dump(q); + } +#endif + htb_delay_by (sch,min_delay); + DEVIK_MEND(4); +fin: + HTB_DBG(3,1,"htb_deq_end %s j=%lu skb=%p\n",sch->dev->name,jiffies,skb); + DEVIK_MEND(2); + return skb; +} + +/* try to drop from each class (by prio) until one succeed */ +static int htb_drop(struct Qdisc* sch) +{ + struct htb_sched *q = (struct htb_sched *)sch->data; + int prio; + + for (prio = TC_HTB_NUMPRIO - 1; prio >= 0; prio--) { + struct list_head *p; + list_for_each (p,q->drops+prio) { + struct htb_class *cl = list_entry(p,struct htb_class, + un.leaf.drop_list); + if (cl->un.leaf.q->ops->drop && + cl->un.leaf.q->ops->drop(cl->un.leaf.q)) { + sch->q.qlen--; + if (!cl->un.leaf.q->q.qlen) + htb_deactivate (q,cl); + return 1; + } + } + } + return 0; +} + +/* reset all classes */ +/* always caled under BH & queue lock */ +static void htb_reset(struct Qdisc* sch) +{ + struct htb_sched *q = (struct htb_sched *)sch->data; + int i; + HTB_DBG(0,1,"htb_reset sch=%p, handle=%X\n",sch,sch->handle); + + for (i = 0; i < HTB_HSIZE; i++) { + struct list_head *p; + list_for_each (p,q->hash+i) { + struct htb_class *cl = list_entry(p,struct htb_class,hlist); + if (cl->level) + memset(&cl->un.inner,0,sizeof(cl->un.inner)); + else { + if (cl->un.leaf.q) + qdisc_reset(cl->un.leaf.q); + INIT_LIST_HEAD(&cl->un.leaf.drop_list); + } + cl->prio_activity = 0; + cl->cmode = HTB_CAN_SEND; +#ifdef HTB_DEBUG + cl->pq_node.rb_color = -1; + memset(cl->node,255,sizeof(cl->node)); +#endif + + } + } + sch->flags &= ~TCQ_F_THROTTLED; + del_timer(&q->timer); + __skb_queue_purge(&q->direct_queue); + sch->q.qlen = 0; + memset(q->row,0,sizeof(q->row)); + memset(q->row_mask,0,sizeof(q->row_mask)); + memset(q->wait_pq,0,sizeof(q->wait_pq)); + memset(q->ptr,0,sizeof(q->ptr)); + for (i = 0; i < TC_HTB_NUMPRIO; i++) + INIT_LIST_HEAD(q->drops+i); +} + +static int htb_init(struct Qdisc *sch, struct rtattr *opt) +{ + struct htb_sched *q = (struct htb_sched*)sch->data; + struct rtattr *tb[TCA_HTB_INIT]; + struct tc_htb_glob *gopt; + int i; +#ifdef HTB_DEBUG + printk(KERN_INFO "HTB init, kernel part version %d.%d\n", + HTB_VER >> 16,HTB_VER & 0xffff); +#endif + if (!opt || rtattr_parse(tb, TCA_HTB_INIT, RTA_DATA(opt), RTA_PAYLOAD(opt)) || + tb[TCA_HTB_INIT-1] == NULL || + RTA_PAYLOAD(tb[TCA_HTB_INIT-1]) < sizeof(*gopt)) { + printk(KERN_ERR "HTB: hey probably you have bad tc tool ?\n"); + return -EINVAL; + } + gopt = RTA_DATA(tb[TCA_HTB_INIT-1]); + if (gopt->version != HTB_VER >> 16) { + printk(KERN_ERR "HTB: need tc/htb version %d (minor is %d), you have %d\n", + HTB_VER >> 16,HTB_VER & 0xffff,gopt->version); + return -EINVAL; + } + memset(q,0,sizeof(*q)); + q->debug = gopt->debug; + HTB_DBG(0,1,"htb_init sch=%p handle=%X r2q=%d\n",sch,sch->handle,gopt->rate2quantum); + + INIT_LIST_HEAD(&q->root); + for (i = 0; i < HTB_HSIZE; i++) + INIT_LIST_HEAD(q->hash+i); + for (i = 0; i < TC_HTB_NUMPRIO; i++) + INIT_LIST_HEAD(q->drops+i); + + init_timer(&q->timer); + skb_queue_head_init(&q->direct_queue); + + q->direct_qlen = sch->dev->tx_queue_len; + q->timer.function = htb_timer; + q->timer.data = (unsigned long)sch; + +#ifdef HTB_RATECM + init_timer(&q->rttim); + q->rttim.function = htb_rate_timer; + q->rttim.data = (unsigned long)sch; + q->rttim.expires = jiffies + HZ; + add_timer(&q->rttim); +#endif + if ((q->rate2quantum = gopt->rate2quantum) < 1) + q->rate2quantum = 1; + q->defcls = gopt->defcls; + + MOD_INC_USE_COUNT; + return 0; +} + +static int htb_dump(struct Qdisc *sch, struct sk_buff *skb) +{ + struct htb_sched *q = (struct htb_sched*)sch->data; + unsigned char *b = skb->tail; + struct rtattr *rta; + struct tc_htb_glob gopt; + HTB_DBG(0,1,"htb_dump sch=%p, handle=%X\n",sch,sch->handle); + /* stats */ + HTB_QLOCK(sch); + gopt.direct_pkts = q->direct_pkts; + +#ifdef HTB_DEBUG + htb_debug_dump(q); +#endif + gopt.version = HTB_VER; + gopt.rate2quantum = q->rate2quantum; + gopt.defcls = q->defcls; + gopt.debug = q->debug; + rta = (struct rtattr*)b; + RTA_PUT(skb, TCA_OPTIONS, 0, NULL); + RTA_PUT(skb, TCA_HTB_INIT, sizeof(gopt), &gopt); + rta->rta_len = skb->tail - b; + sch->stats.qlen = sch->q.qlen; + RTA_PUT(skb, TCA_STATS, sizeof(sch->stats), &sch->stats); + HTB_QUNLOCK(sch); + return skb->len; +rtattr_failure: + HTB_QUNLOCK(sch); + skb_trim(skb, skb->tail - skb->data); + return -1; +} + +static int htb_dump_class(struct Qdisc *sch, unsigned long arg, + struct sk_buff *skb, struct tcmsg *tcm) +{ +#ifdef HTB_DEBUG + struct htb_sched *q = (struct htb_sched*)sch->data; +#endif + struct htb_class *cl = (struct htb_class*)arg; + unsigned char *b = skb->tail; + struct rtattr *rta; + struct tc_htb_opt opt; + + HTB_DBG(0,1,"htb_dump_class handle=%X clid=%X\n",sch->handle,cl->classid); + + HTB_QLOCK(sch); + tcm->tcm_parent = cl->parent ? cl->parent->classid : TC_H_ROOT; + tcm->tcm_handle = cl->classid; + if (!cl->level && cl->un.leaf.q) { + tcm->tcm_info = cl->un.leaf.q->handle; + cl->stats.qlen = cl->un.leaf.q->q.qlen; + } + + rta = (struct rtattr*)b; + RTA_PUT(skb, TCA_OPTIONS, 0, NULL); + + memset (&opt,0,sizeof(opt)); + + opt.rate = cl->rate->rate; opt.buffer = cl->buffer; + opt.ceil = cl->ceil->rate; opt.cbuffer = cl->cbuffer; + opt.quantum = cl->un.leaf.quantum; opt.prio = cl->un.leaf.prio; + opt.level = cl->level; + RTA_PUT(skb, TCA_HTB_PARMS, sizeof(opt), &opt); + rta->rta_len = skb->tail - b; + +#ifdef HTB_RATECM + cl->stats.bps = cl->rate_bytes/(HTB_EWMAC*HTB_HSIZE); + cl->stats.pps = cl->rate_packets/(HTB_EWMAC*HTB_HSIZE); +#endif + + cl->xstats.tokens = cl->tokens; + cl->xstats.ctokens = cl->ctokens; + RTA_PUT(skb, TCA_STATS, sizeof(cl->stats), &cl->stats); + RTA_PUT(skb, TCA_XSTATS, sizeof(cl->xstats), &cl->xstats); + HTB_QUNLOCK(sch); + return skb->len; +rtattr_failure: + HTB_QUNLOCK(sch); + skb_trim(skb, b - skb->data); + return -1; +} + +static int htb_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, + struct Qdisc **old) +{ + struct htb_class *cl = (struct htb_class*)arg; + + if (cl && !cl->level) { + if (new == NULL && (new = qdisc_create_dflt(sch->dev, + &pfifo_qdisc_ops)) == NULL) + return -ENOBUFS; + sch_tree_lock(sch); + if ((*old = xchg(&cl->un.leaf.q, new)) != NULL) { + /* TODO: is it correct ? Why CBQ doesn't do it ? */ + sch->q.qlen -= (*old)->q.qlen; + qdisc_reset(*old); + } + sch_tree_unlock(sch); + return 0; + } + return -ENOENT; +} + +static struct Qdisc * htb_leaf(struct Qdisc *sch, unsigned long arg) +{ + struct htb_class *cl = (struct htb_class*)arg; + return (cl && !cl->level) ? cl->un.leaf.q : NULL; +} + +static unsigned long htb_get(struct Qdisc *sch, u32 classid) +{ +#ifdef HTB_DEBUG + struct htb_sched *q = (struct htb_sched *)sch->data; +#endif + struct htb_class *cl = htb_find(classid,sch); + HTB_DBG(0,1,"htb_get clid=%X q=%p cl=%p ref=%d\n",classid,q,cl,cl?cl->refcnt:0); + if (cl) + cl->refcnt++; + return (unsigned long)cl; +} + +static void htb_destroy_filters(struct tcf_proto **fl) +{ + struct tcf_proto *tp; + + while ((tp = *fl) != NULL) { + *fl = tp->next; + tp->ops->destroy(tp); + } +} + +static void htb_destroy_class(struct Qdisc* sch,struct htb_class *cl) +{ + struct htb_sched *q = (struct htb_sched *)sch->data; + HTB_DBG(0,1,"htb_destrycls clid=%X ref=%d\n", cl?cl->classid:0,cl?cl->refcnt:0); + if (!cl->level) { + BUG_TRAP(cl->un.leaf.q); + sch->q.qlen -= cl->un.leaf.q->q.qlen; + qdisc_destroy(cl->un.leaf.q); + } + qdisc_put_rtab(cl->rate); + qdisc_put_rtab(cl->ceil); + +#ifdef CONFIG_NET_ESTIMATOR + qdisc_kill_estimator(&cl->stats); +#endif + htb_destroy_filters (&cl->filter_list); + + while (!list_empty(&cl->children)) + htb_destroy_class (sch,list_entry(cl->children.next, + struct htb_class,sibling)); + + /* note: this delete may happen twice (see htb_delete) */ + list_del(&cl->hlist); + list_del(&cl->sibling); + + if (cl->prio_activity) + htb_deactivate (q,cl); + + if (cl->cmode != HTB_CAN_SEND) + htb_safe_rb_erase(&cl->pq_node,q->wait_pq+cl->level); + + kfree(cl); +} + +/* always caled under BH & queue lock */ +static void htb_destroy(struct Qdisc* sch) +{ + struct htb_sched *q = (struct htb_sched *)sch->data; + HTB_DBG(0,1,"htb_destroy q=%p\n",q); + + del_timer_sync (&q->timer); +#ifdef HTB_RATECM + del_timer_sync (&q->rttim); +#endif + while (!list_empty(&q->root)) + htb_destroy_class (sch,list_entry(q->root.next, + struct htb_class,sibling)); + + htb_destroy_filters(&q->filter_list); + __skb_queue_purge(&q->direct_queue); + MOD_DEC_USE_COUNT; +} + +static int htb_delete(struct Qdisc *sch, unsigned long arg) +{ + struct htb_sched *q = (struct htb_sched *)sch->data; + struct htb_class *cl = (struct htb_class*)arg; + HTB_DBG(0,1,"htb_delete q=%p cl=%X ref=%d\n",q,cl?cl->classid:0,cl?cl->refcnt:0); + + // TODO: why don't allow to delete subtree ? references ? does + // tc subsys quarantee us that in htb_destroy it holds no class + // refs so that we can remove children safely there ? + if (!list_empty(&cl->children) || cl->filter_cnt) + return -EBUSY; + + sch_tree_lock(sch); + + /* delete from hash and active; remainder in destroy_class */ + list_del_init(&cl->hlist); + if (cl->prio_activity) + htb_deactivate (q,cl); + + if (--cl->refcnt == 0) + htb_destroy_class(sch,cl); + + sch_tree_unlock(sch); + return 0; +} + +static void htb_put(struct Qdisc *sch, unsigned long arg) +{ +#ifdef HTB_DEBUG + struct htb_sched *q = (struct htb_sched *)sch->data; +#endif + struct htb_class *cl = (struct htb_class*)arg; + HTB_DBG(0,1,"htb_put q=%p cl=%X ref=%d\n",q,cl?cl->classid:0,cl?cl->refcnt:0); + + if (--cl->refcnt == 0) + htb_destroy_class(sch,cl); +} + +static int htb_change_class(struct Qdisc *sch, u32 classid, + u32 parentid, struct rtattr **tca, unsigned long *arg) +{ + int err = -EINVAL; + struct htb_sched *q = (struct htb_sched *)sch->data; + struct htb_class *cl = (struct htb_class*)*arg,*parent; + struct rtattr *opt = tca[TCA_OPTIONS-1]; + struct qdisc_rate_table *rtab = NULL, *ctab = NULL; + struct rtattr *tb[TCA_HTB_RTAB]; + struct tc_htb_opt *hopt; + + /* extract all subattrs from opt attr */ + if (!opt || rtattr_parse(tb, TCA_HTB_RTAB, RTA_DATA(opt), RTA_PAYLOAD(opt)) || + tb[TCA_HTB_PARMS-1] == NULL || + RTA_PAYLOAD(tb[TCA_HTB_PARMS-1]) < sizeof(*hopt)) + goto failure; + + parent = parentid == TC_H_ROOT ? NULL : htb_find (parentid,sch); + + hopt = RTA_DATA(tb[TCA_HTB_PARMS-1]); + HTB_DBG(0,1,"htb_chg cl=%p, clid=%X, opt/prio=%d, rate=%u, buff=%d, quant=%d\n", cl,cl?cl->classid:0,(int)hopt->prio,hopt->rate.rate,hopt->buffer,hopt->quantum); + rtab = qdisc_get_rtab(&hopt->rate, tb[TCA_HTB_RTAB-1]); + ctab = qdisc_get_rtab(&hopt->ceil, tb[TCA_HTB_CTAB-1]); + if (!rtab || !ctab) goto failure; + + if (!cl) { /* new class */ + /* check maximal depth */ + if (parent && parent->parent && parent->parent->level < 2) { + printk(KERN_ERR "htb: tree is too deep\n"); + goto failure; + } + err = -ENOBUFS; + if ((cl = kmalloc(sizeof(*cl), GFP_KERNEL)) == NULL) + goto failure; + + memset(cl, 0, sizeof(*cl)); + cl->refcnt = 1; + INIT_LIST_HEAD(&cl->sibling); + INIT_LIST_HEAD(&cl->hlist); + INIT_LIST_HEAD(&cl->children); + INIT_LIST_HEAD(&cl->un.leaf.drop_list); +#ifdef HTB_DEBUG + cl->magic = HTB_CMAGIC; +#endif + + sch_tree_lock(sch); + if (parent && !parent->level) { + /* turn parent into inner node */ + sch->q.qlen -= parent->un.leaf.q->q.qlen; + qdisc_destroy (parent->un.leaf.q); + if (parent->prio_activity) + htb_deactivate (q,parent); + + /* remove from evt list because of level change */ + if (parent->cmode != HTB_CAN_SEND) { + htb_safe_rb_erase(&parent->pq_node,q->wait_pq /*+0*/); + parent->cmode = HTB_CAN_SEND; + } + parent->level = (parent->parent ? parent->parent->level + : TC_HTB_MAXDEPTH) - 1; + memset (&parent->un.inner,0,sizeof(parent->un.inner)); + } + /* leaf (we) needs elementary qdisc */ + if (!(cl->un.leaf.q = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops))) + cl->un.leaf.q = &noop_qdisc; + + cl->classid = classid; cl->parent = parent; + + /* set class to be in HTB_CAN_SEND state */ + cl->tokens = hopt->buffer; + cl->ctokens = hopt->cbuffer; + cl->mbuffer = 60000000; /* 1min */ + PSCHED_GET_TIME(cl->t_c); + cl->cmode = HTB_CAN_SEND; + + /* attach to the hash list and parent's family */ + list_add_tail(&cl->hlist, q->hash+htb_hash(classid)); + list_add_tail(&cl->sibling, parent ? &parent->children : &q->root); +#ifdef HTB_DEBUG + { + int i; + for (i = 0; i < TC_HTB_NUMPRIO; i++) cl->node[i].rb_color = -1; + cl->pq_node.rb_color = -1; + } +#endif + } else sch_tree_lock(sch); + + cl->un.leaf.quantum = rtab->rate.rate / q->rate2quantum; + if (!hopt->quantum && cl->un.leaf.quantum < 1000) { + printk(KERN_WARNING "HTB: quantum of class %X is small. Consider r2q change.", cl->classid); + cl->un.leaf.quantum = 1000; + } + if (!hopt->quantum && cl->un.leaf.quantum > 200000) { + printk(KERN_WARNING "HTB: quantum of class %X is big. Consider r2q change.", cl->classid); + cl->un.leaf.quantum = 200000; + } + if (hopt->quantum) + cl->un.leaf.quantum = hopt->quantum; + if ((cl->un.leaf.prio = hopt->prio) >= TC_HTB_NUMPRIO) + cl->un.leaf.prio = TC_HTB_NUMPRIO - 1; + + cl->buffer = hopt->buffer; + cl->cbuffer = hopt->cbuffer; + if (cl->rate) qdisc_put_rtab(cl->rate); cl->rate = rtab; + if (cl->ceil) qdisc_put_rtab(cl->ceil); cl->ceil = ctab; + sch_tree_unlock(sch); + + *arg = (unsigned long)cl; + return 0; + +failure: + if (rtab) qdisc_put_rtab(rtab); + if (ctab) qdisc_put_rtab(ctab); + return err; +} + +static struct tcf_proto **htb_find_tcf(struct Qdisc *sch, unsigned long arg) +{ + struct htb_sched *q = (struct htb_sched *)sch->data; + struct htb_class *cl = (struct htb_class *)arg; + struct tcf_proto **fl = cl ? &cl->filter_list : &q->filter_list; + HTB_DBG(0,2,"htb_tcf q=%p clid=%X fref=%d fl=%p\n",q,cl?cl->classid:0,cl?cl->filter_cnt:q->filter_cnt,*fl); + return fl; +} + +static unsigned long htb_bind_filter(struct Qdisc *sch, unsigned long parent, + u32 classid) +{ + struct htb_sched *q = (struct htb_sched *)sch->data; + struct htb_class *cl = htb_find (classid,sch); + HTB_DBG(0,2,"htb_bind q=%p clid=%X cl=%p fref=%d\n",q,classid,cl,cl?cl->filter_cnt:q->filter_cnt); + /*if (cl && !cl->level) return 0; + The line above used to be there to prevent attaching filters to + leaves. But at least tc_index filter uses this just to get class + for other reasons so that we have to allow for it. + ---- + 19.6.2002 As Werner explained it is ok - bind filter is just + another way to "lock" the class - unlike "get" this lock can + be broken by class during destroy IIUC. + */ + if (cl) + cl->filter_cnt++; + else + q->filter_cnt++; + return (unsigned long)cl; +} + +static void htb_unbind_filter(struct Qdisc *sch, unsigned long arg) +{ + struct htb_sched *q = (struct htb_sched *)sch->data; + struct htb_class *cl = (struct htb_class *)arg; + HTB_DBG(0,2,"htb_unbind q=%p cl=%p fref=%d\n",q,cl,cl?cl->filter_cnt:q->filter_cnt); + if (cl) + cl->filter_cnt--; + else + q->filter_cnt--; +} + +static void htb_walk(struct Qdisc *sch, struct qdisc_walker *arg) +{ + struct htb_sched *q = (struct htb_sched *)sch->data; + int i; + + if (arg->stop) + return; + + for (i = 0; i < HTB_HSIZE; i++) { + struct list_head *p; + list_for_each (p,q->hash+i) { + struct htb_class *cl = list_entry(p,struct htb_class,hlist); + if (arg->count < arg->skip) { + arg->count++; + continue; + } + if (arg->fn(sch, (unsigned long)cl, arg) < 0) { + arg->stop = 1; + return; + } + arg->count++; + } + } +} + +static struct Qdisc_class_ops htb_class_ops = +{ + htb_graft, + htb_leaf, + htb_get, + htb_put, + htb_change_class, + htb_delete, + htb_walk, + + htb_find_tcf, + htb_bind_filter, + htb_unbind_filter, + + htb_dump_class, +}; + +struct Qdisc_ops htb_qdisc_ops = +{ + NULL, + &htb_class_ops, + "htb", + sizeof(struct htb_sched), + + htb_enqueue, + htb_dequeue, + htb_requeue, + htb_drop, + + htb_init, + htb_reset, + htb_destroy, + NULL /* htb_change */, + + htb_dump, +}; + +#ifdef MODULE +int init_module(void) +{ + return register_qdisc(&htb_qdisc_ops); +} + +void cleanup_module(void) +{ + unregister_qdisc(&htb_qdisc_ops); +} +MODULE_LICENSE("GPL"); +#endif diff --git a/net/socket.c b/net/socket.c index 680b617772f3..53dcf8bf9c83 100644 --- a/net/socket.c +++ b/net/socket.c @@ -112,18 +112,18 @@ static ssize_t sock_sendpage(struct file *file, struct page *page, */ static struct file_operations socket_file_ops = { - llseek: no_llseek, - read: sock_read, - write: sock_write, - poll: sock_poll, - ioctl: sock_ioctl, - mmap: sock_mmap, - open: sock_no_open, /* special open code to disallow open via /proc */ - release: sock_close, - fasync: sock_fasync, - readv: sock_readv, - writev: sock_writev, - sendpage: sock_sendpage + .llseek = no_llseek, + .read = sock_read, + .write = sock_write, + .poll = sock_poll, + .ioctl = sock_ioctl, + .mmap = sock_mmap, + .open = sock_no_open, /* special open code to disallow open via /proc */ + .release = sock_close, + .fasync = sock_fasync, + .readv = sock_readv, + .writev = sock_writev, + .sendpage = sock_sendpage }; /* @@ -312,9 +312,9 @@ static int init_inodecache(void) } static struct super_operations sockfs_ops = { - alloc_inode: sock_alloc_inode, - destroy_inode: sock_destroy_inode, - statfs: simple_statfs, + .alloc_inode = sock_alloc_inode, + .destroy_inode =sock_destroy_inode, + .statfs = simple_statfs, }; static struct super_block *sockfs_get_sb(struct file_system_type *fs_type, @@ -326,16 +326,16 @@ static struct super_block *sockfs_get_sb(struct file_system_type *fs_type, static struct vfsmount *sock_mnt; static struct file_system_type sock_fs_type = { - name: "sockfs", - get_sb: sockfs_get_sb, - kill_sb: kill_anon_super, + .name = "sockfs", + .get_sb = sockfs_get_sb, + .kill_sb = kill_anon_super, }; static int sockfs_delete_dentry(struct dentry *dentry) { return 1; } static struct dentry_operations sockfs_dentry_operations = { - d_delete: sockfs_delete_dentry, + .d_delete = sockfs_delete_dentry, }; /* diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index db9b83bb6384..02b1b02bdbd8 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -1816,50 +1816,50 @@ done: #endif struct proto_ops unix_stream_ops = { - family: PF_UNIX, + .family = PF_UNIX, - release: unix_release, - bind: unix_bind, - connect: unix_stream_connect, - socketpair: unix_socketpair, - accept: unix_accept, - getname: unix_getname, - poll: unix_poll, - ioctl: unix_ioctl, - listen: unix_listen, - shutdown: unix_shutdown, - setsockopt: sock_no_setsockopt, - getsockopt: sock_no_getsockopt, - sendmsg: unix_stream_sendmsg, - recvmsg: unix_stream_recvmsg, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .release = unix_release, + .bind = unix_bind, + .connect = unix_stream_connect, + .socketpair = unix_socketpair, + .accept = unix_accept, + .getname = unix_getname, + .poll = unix_poll, + .ioctl = unix_ioctl, + .listen = unix_listen, + .shutdown = unix_shutdown, + .setsockopt = sock_no_setsockopt, + .getsockopt = sock_no_getsockopt, + .sendmsg = unix_stream_sendmsg, + .recvmsg = unix_stream_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; struct proto_ops unix_dgram_ops = { - family: PF_UNIX, - - release: unix_release, - bind: unix_bind, - connect: unix_dgram_connect, - socketpair: unix_socketpair, - accept: sock_no_accept, - getname: unix_getname, - poll: datagram_poll, - ioctl: unix_ioctl, - listen: sock_no_listen, - shutdown: unix_shutdown, - setsockopt: sock_no_setsockopt, - getsockopt: sock_no_getsockopt, - sendmsg: unix_dgram_sendmsg, - recvmsg: unix_dgram_recvmsg, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = PF_UNIX, + + .release = unix_release, + .bind = unix_bind, + .connect = unix_dgram_connect, + .socketpair = unix_socketpair, + .accept = sock_no_accept, + .getname = unix_getname, + .poll = datagram_poll, + .ioctl = unix_ioctl, + .listen = sock_no_listen, + .shutdown = unix_shutdown, + .setsockopt = sock_no_setsockopt, + .getsockopt = sock_no_getsockopt, + .sendmsg = unix_dgram_sendmsg, + .recvmsg = unix_dgram_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; struct net_proto_family unix_family_ops = { - family: PF_UNIX, - create: unix_create, + .family = PF_UNIX, + .create = unix_create, }; #ifdef CONFIG_SYSCTL diff --git a/net/wanrouter/af_wanpipe.c b/net/wanrouter/af_wanpipe.c index 0a9f62073788..cf585a136e29 100644 --- a/net/wanrouter/af_wanpipe.c +++ b/net/wanrouter/af_wanpipe.c @@ -2697,22 +2697,22 @@ static int wanpipe_connect(struct socket *sock, struct sockaddr *uaddr, int addr #ifdef LINUX_2_4 struct proto_ops wanpipe_ops = { - family: PF_WANPIPE, - - release: wanpipe_release, - bind: wanpipe_bind, - connect: wanpipe_connect, - socketpair: sock_no_socketpair, - accept: wanpipe_accept, - getname: wanpipe_getname, - poll: wanpipe_poll, - ioctl: wanpipe_ioctl, - listen: wanpipe_listen, - shutdown: sock_no_shutdown, - setsockopt: sock_no_setsockopt, - getsockopt: sock_no_getsockopt, - sendmsg: wanpipe_sendmsg, - recvmsg: wanpipe_recvmsg + .family = PF_WANPIPE, + + .release = wanpipe_release, + .bind = wanpipe_bind, + .connect = wanpipe_connect, + .socketpair = sock_no_socketpair, + .accept = wanpipe_accept, + .getname = wanpipe_getname, + .poll = wanpipe_poll, + .ioctl = wanpipe_ioctl, + .listen = wanpipe_listen, + .shutdown = sock_no_shutdown, + .setsockopt = sock_no_setsockopt, + .getsockopt = sock_no_getsockopt, + .sendmsg = wanpipe_sendmsg, + .recvmsg = wanpipe_recvmsg }; #else struct proto_ops wanpipe_ops = { @@ -2739,12 +2739,12 @@ struct proto_ops wanpipe_ops = { static struct net_proto_family wanpipe_family_ops = { - family: PF_WANPIPE, - create: wanpipe_create, + .family =PF_WANPIPE, + .create =wanpipe_create, }; struct notifier_block wanpipe_netdev_notifier = { - notifier_call: wanpipe_notifier, + .notifier_call =wanpipe_notifier, }; diff --git a/net/wanrouter/wanproc.c b/net/wanrouter/wanproc.c index f27ee2df571b..b3ba10e04e66 100644 --- a/net/wanrouter/wanproc.c +++ b/net/wanrouter/wanproc.c @@ -81,7 +81,7 @@ static int router_proc_perms(struct inode *, int); static struct inode_operations router_inode = { - permission: router_proc_perms, + .permission = router_proc_perms, }; /* @@ -194,17 +194,17 @@ static int status_show(struct seq_file *m, void *v) } static struct seq_operations config_op = { - start: r_start, - next: r_next, - stop: r_stop, - show: config_show + .start =r_start, + .next = r_next, + .stop = r_stop, + .show = config_show }; static struct seq_operations status_op = { - start: r_start, - next: r_next, - stop: r_stop, - show: status_show + .start =r_start, + .next = r_next, + .stop = r_stop, + .show = status_show }; static int config_open(struct inode *inode, struct file *file) @@ -219,18 +219,18 @@ static int status_open(struct inode *inode, struct file *file) static struct file_operations config_fops = { - open: config_open, - read: seq_read, - llseek: seq_lseek, - release: seq_release, + .open = config_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, }; static struct file_operations status_fops = { - open: status_open, - read: seq_read, - llseek: seq_lseek, - release: seq_release, + .open = status_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, }; static int wandev_show(struct seq_file *m, void *v) @@ -302,11 +302,11 @@ static int wandev_open(struct inode *inode, struct file *file) static struct file_operations wandev_fops = { - open: wandev_open, - read: seq_read, - llseek: seq_lseek, - release: single_release, - ioctl: wanrouter_ioctl, + .open = wandev_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .ioctl = wanrouter_ioctl, }; /* diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index aba8ec2954af..3a7f8165865c 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -1278,29 +1278,29 @@ static int x25_get_info(char *buffer, char **start, off_t offset, int length) } struct net_proto_family x25_family_ops = { - family: AF_X25, - create: x25_create, + .family = AF_X25, + .create = x25_create, }; static struct proto_ops SOCKOPS_WRAPPED(x25_proto_ops) = { - family: AF_X25, - - release: x25_release, - bind: x25_bind, - connect: x25_connect, - socketpair: sock_no_socketpair, - accept: x25_accept, - getname: x25_getname, - poll: datagram_poll, - ioctl: x25_ioctl, - listen: x25_listen, - shutdown: sock_no_shutdown, - setsockopt: x25_setsockopt, - getsockopt: x25_getsockopt, - sendmsg: x25_sendmsg, - recvmsg: x25_recvmsg, - mmap: sock_no_mmap, - sendpage: sock_no_sendpage, + .family = AF_X25, + + .release = x25_release, + .bind = x25_bind, + .connect = x25_connect, + .socketpair = sock_no_socketpair, + .accept = x25_accept, + .getname = x25_getname, + .poll = datagram_poll, + .ioctl = x25_ioctl, + .listen = x25_listen, + .shutdown = sock_no_shutdown, + .setsockopt = x25_setsockopt, + .getsockopt = x25_getsockopt, + .sendmsg = x25_sendmsg, + .recvmsg = x25_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, }; #include <linux/smp_lock.h> @@ -1308,12 +1308,12 @@ SOCKOPS_WRAP(x25_proto, AF_X25); static struct packet_type x25_packet_type = { - type: __constant_htons(ETH_P_X25), - func: x25_lapb_receive_frame, + .type = __constant_htons(ETH_P_X25), + .func = x25_lapb_receive_frame, }; struct notifier_block x25_dev_notifier = { - notifier_call: x25_device_event, + .notifier_call =x25_device_event, }; void x25_kill_by_neigh(struct x25_neigh *neigh) |
