Commit eaf7c976 authored by David S. Miller's avatar David S. Miller

Merge davem@nuts.ninka.net:/home/davem/src/BK/net-2.5

into kernel.bkbits.net:/home/davem/net-2.5
parents ad6ea5a3 a536a9b2
No related merge requests found
......@@ -2013,7 +2013,7 @@ static int __init apm_init(void)
apm_proc = create_proc_info_entry("apm", 0, NULL, apm_get_info);
if (apm_proc)
SET_MODULE_OWNER(apm_proc);
apm_proc->owner = THIS_MODULE;
kernel_thread(apm, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND | SIGCHLD);
......
......@@ -757,7 +757,7 @@ int __init i8k_init(void)
return -ENOENT;
}
proc_i8k->proc_fops = &i8k_fops;
SET_MODULE_OWNER(proc_i8k);
proc_i8k->owner = THIS_MODULE;
printk(KERN_INFO
"Dell laptop SMM driver v%s Massimo Dal Zotto (dz@debian.org)\n",
......
......@@ -587,7 +587,7 @@ act2000_alloccard(int bus, int port, int irq, char *id)
INIT_WORK(&card->rcv_tq, (void *) (void *) actcapi_dispatch, card);
INIT_WORK(&card->poll_tq, (void *) (void *) act2000_receive, card);
init_timer(&card->ptimer);
SET_MODULE_OWNER(&card->interface);
card->interface.owner = THIS_MODULE;
card->interface.channels = ACT2000_BCH;
card->interface.maxbufsize = 4000;
card->interface.command = if_command;
......
......@@ -834,7 +834,7 @@ eicon_alloccard(int Type, int membase, int irq, char *id, int card_id)
tasklet_init(&card->snd_tq, eicon_transmit, (unsigned long)card);
tasklet_init(&card->rcv_tq, eicon_rcv_dispatch, (unsigned long)card);
tasklet_init(&card->ack_tq, eicon_ack_dispatch, (unsigned long)card);
SET_MODULE_OWNER(&card->interface);
card->interface.owner = THIS_MODULE;
card->interface.maxbufsize = 4000;
card->interface.command = if_command;
card->interface.writebuf_skb = if_sendbuf;
......
......@@ -118,7 +118,7 @@ static int __init b1isa_probe(struct pci_dev *pdev)
cinfo->capi_ctrl.procinfo = b1isa_procinfo;
cinfo->capi_ctrl.ctr_read_proc = b1ctl_read_proc;
strcpy(cinfo->capi_ctrl.name, card->name);
SET_MODULE_OWNER(&cinfo->capi_ctrl);
cinfo->capi_ctrl.owner = THIS_MODULE;
retval = attach_capi_ctr(&cinfo->capi_ctrl);
if (retval) {
......
......@@ -111,7 +111,7 @@ static int b1pci_probe(struct capicardparams *p, struct pci_dev *pdev)
cinfo->capi_ctrl.procinfo = b1pci_procinfo;
cinfo->capi_ctrl.ctr_read_proc = b1ctl_read_proc;
strcpy(cinfo->capi_ctrl.name, card->name);
SET_MODULE_OWNER(&cinfo->capi_ctrl);
cinfo->capi_ctrl.owner = THIS_MODULE;
retval = attach_capi_ctr(&cinfo->capi_ctrl);
if (retval) {
......@@ -249,7 +249,7 @@ static int b1pciv4_probe(struct capicardparams *p, struct pci_dev *pdev)
cinfo->capi_ctrl.procinfo = b1pciv4_procinfo;
cinfo->capi_ctrl.ctr_read_proc = b1dmactl_read_proc;
strcpy(cinfo->capi_ctrl.name, card->name);
SET_MODULE_OWNER(&cinfo->capi_ctrl);
cinfo->capi_ctrl.owner = THIS_MODULE;
retval = attach_capi_ctr(&cinfo->capi_ctrl);
if (retval) {
......
......@@ -105,7 +105,7 @@ static int b1pcmcia_add_card(unsigned int port, unsigned irq,
cinfo->capi_ctrl.procinfo = b1pcmcia_procinfo;
cinfo->capi_ctrl.ctr_read_proc = b1ctl_read_proc;
strcpy(cinfo->capi_ctrl.name, card->name);
SET_MODULE_OWNER(&cinfo->capi_ctrl);
cinfo->capi_ctrl.owner = THIS_MODULE;
retval = attach_capi_ctr(&cinfo->capi_ctrl);
if (retval) {
......
......@@ -1166,7 +1166,7 @@ static int c4_add_card(struct capicardparams *p, struct pci_dev *dev,
cinfo->capi_ctrl.procinfo = c4_procinfo;
cinfo->capi_ctrl.ctr_read_proc = c4_read_proc;
strcpy(cinfo->capi_ctrl.name, card->name);
SET_MODULE_OWNER(&cinfo->capi_ctrl);
cinfo->capi_ctrl.owner = THIS_MODULE;
retval = attach_capi_ctr(&cinfo->capi_ctrl);
if (retval) {
......
......@@ -411,7 +411,7 @@ static int __init t1isa_probe(struct pci_dev *pdev, int cardnr)
cinfo->capi_ctrl.procinfo = t1isa_procinfo;
cinfo->capi_ctrl.ctr_read_proc = b1ctl_read_proc;
strcpy(cinfo->capi_ctrl.name, card->name);
SET_MODULE_OWNER(&cinfo->capi_ctrl);
cinfo->capi_ctrl.owner = THIS_MODULE;
retval = attach_capi_ctr(&cinfo->capi_ctrl);
if (retval) {
......
......@@ -119,7 +119,7 @@ static int t1pci_add_card(struct capicardparams *p, struct pci_dev *pdev)
cinfo->capi_ctrl.procinfo = t1pci_procinfo;
cinfo->capi_ctrl.ctr_read_proc = b1dmactl_read_proc;
strcpy(cinfo->capi_ctrl.name, card->name);
SET_MODULE_OWNER(&cinfo->capi_ctrl);
cinfo->capi_ctrl.owner = THIS_MODULE;
retval = attach_capi_ctr(&cinfo->capi_ctrl);
if (retval) {
......
......@@ -149,7 +149,7 @@ void diva_os_set_controller_struct(struct capi_ctr *ctrl)
ctrl->load_firmware = 0;
ctrl->reset_ctr = 0;
ctrl->ctr_read_proc = diva_ctl_read_proc;
SET_MODULE_OWNER(ctrl);
ctrl->owner = THIS_MODULE;
}
/*
......
......@@ -913,7 +913,7 @@ eicon_alloccard(DESCRIPTOR *d)
skb_queue_head_init(&card->sackq);
skb_queue_head_init(&card->statq);
card->statq_entries = 0;
SET_MODULE_OWNER(&card->interface);
card->interface.owner = THIS_MODULE;
card->interface.maxbufsize = 4000;
card->interface.command = if_command;
card->interface.writebuf_skb = if_sendbuf;
......
......@@ -889,7 +889,7 @@ static int __devinit checkcard(int cardnr, char *id, int *busy_flag)
"HiSax: Card Type %d out of range\n", card->typ);
goto outf_cs;
}
SET_MODULE_OWNER(&cs->iif);
cs->iif.owner = THIS_MODULE;
strcpy(cs->iif.id, id);
cs->iif.channels = 2;
cs->iif.maxbufsize = MAX_DATA_SIZE;
......
......@@ -293,7 +293,7 @@ new_adapter(struct pci_dev *pdev)
memset(adapter, 0, sizeof(struct fritz_adapter));
SET_MODULE_OWNER(&adapter->isac.hisax_d_if);
adapter->isac.hisax_d_if.owner = THIS_MODULE;
adapter->isac.hisax_d_if.ifc.priv = &adapter->isac;
adapter->isac.hisax_d_if.ifc.l2l1 = isac_d_l2l1;
......
......@@ -827,7 +827,7 @@ new_adapter(struct pci_dev *pdev)
memset(adapter, 0, sizeof(struct fritz_adapter));
SET_MODULE_OWNER(&adapter->isac.hisax_d_if);
adapter->isac.hisax_d_if.owner = THIS_MODULE;
adapter->isac.hisax_d_if.ifc.priv = &adapter->isac;
adapter->isac.hisax_d_if.ifc.l2l1 = isac_d_l2l1;
......
......@@ -1484,7 +1484,7 @@ new_adapter(struct pci_dev *pdev)
memset(adapter, 0, sizeof(struct hfcpci_adapter));
SET_MODULE_OWNER(&adapter->d_if);
adapter->d_if.owner = THIS_MODULE;
adapter->d_if.ifc.priv = adapter;
adapter->d_if.ifc.l2l1 = hfcpci_d_l2l1;
......
......@@ -80,7 +80,7 @@ static int probe_st5481(struct usb_interface *intf,
adapter->number_of_leds = number_of_leds;
adapter->usb_dev = dev;
SET_MODULE_OWNER(&adapter->hisax_d_if);
adapter->hisax_d_if.owner = THIS_MODULE;
adapter->hisax_d_if.ifc.priv = adapter;
adapter->hisax_d_if.ifc.l2l1 = st5481_d_l2l1;
......
......@@ -778,7 +778,7 @@ hycapi_capi_create(hysdn_card *card)
ctrl->procinfo = hycapi_procinfo;
ctrl->ctr_read_proc = hycapi_read_proc;
strcpy(ctrl->name, cinfo->cardname);
SET_MODULE_OWNER(ctrl);
ctrl->owner = THIS_MODULE;
retval = attach_capi_ctr(ctrl);
if (retval) {
......
......@@ -1545,7 +1545,7 @@ icn_initcard(int port, char *id)
}
memset((char *) card, 0, sizeof(icn_card));
card->port = port;
SET_MODULE_OWNER(&card->interface);
card->interface.owner = THIS_MODULE;
card->interface.hl_hdrlen = 1;
card->interface.channels = ICN_BCH;
card->interface.maxbufsize = 4000;
......
......@@ -1450,7 +1450,7 @@ isdnloop_initcard(char *id)
return (isdnloop_card *) 0;
}
memset((char *) card, 0, sizeof(isdnloop_card));
SET_MODULE_OWNER(&card->interface);
card->interface.owner = THIS_MODULE;
card->interface.channels = ISDNLOOP_BCH;
card->interface.hl_hdrlen = 1; /* scratch area for storing ack flag*/
card->interface.maxbufsize = 4000;
......
......@@ -171,7 +171,7 @@ int pcbit_init_dev(int board, int mem_base, int irq)
dev->dev_if = dev_if;
SET_MODULE_OWNER(dev_if);
dev_if->owner = THIS_MODULE;
dev_if->channels = 2;
......
......@@ -287,7 +287,7 @@ static int __init sc_init(void)
}
memset(interface, 0, sizeof(isdn_if));
SET_MODULE_OWNER(interface);
interface->owner = THIS_MODULE;
interface->hl_hdrlen = 0;
interface->channels = channels;
interface->maxbufsize = BUFFER_SIZE;
......
......@@ -132,7 +132,7 @@ static int __devinit tpam_probe(struct pci_dev *dev, const struct pci_device_id
copy_to_pam_dword(card, (void *)0x01840070, 0x00000010);
/* fill the ISDN link layer structure */
SET_MODULE_OWNER(&card->interface);
card->interface.owner = THIS_MODULE;
card->interface.channels = TPAM_NBCHANNEL;
card->interface.maxbufsize = TPAM_MAXBUFSIZE;
card->interface.features =
......
......@@ -524,7 +524,7 @@ static int __init apm_emu_init(void)
apm_proc = create_proc_info_entry("apm", 0, NULL, apm_emu_get_info);
if (apm_proc)
SET_MODULE_OWNER(apm_proc);
apm_proc->owner = THIS_MODULE;
misc_register(&apm_device);
......
......@@ -858,7 +858,7 @@ static int munich_probe(void)
board->linecode = SLICECOM_LINECODE_DEFAULT;
board->clock_source = SLICECOM_CLOCK_SOURCE_DEFAULT;
board->loopback = SLICECOM_LOOPBACK_DEFAULT;
SET_MODULE_OWNER(board);
board->owner = THIS_MODULE;
}
else
{
......
......@@ -82,7 +82,7 @@
#include <linux/errno.h> /* return codes */
#include <linux/if_arp.h> /* ARPHRD_HWX25 */
#include <linux/kernel.h> /* printk(), and other useful stuff */
#include <linux/module.h> /* SET_MODULE_OWNER */
#include <linux/module.h>
#include <linux/string.h> /* inline memset(), etc. */
#include <linux/slab.h> /* kmalloc(), kfree() */
#include <linux/stddef.h> /* offsetof(), etc. */
......
......@@ -7,6 +7,8 @@
#ifndef _NET_FLOW_H
#define _NET_FLOW_H
#include <linux/in6.h>
struct flowi {
int oif;
int iif;
......@@ -21,8 +23,8 @@ struct flowi {
} ip4_u;
struct {
struct in6_addr * daddr;
struct in6_addr * saddr;
struct in6_addr daddr;
struct in6_addr saddr;
__u32 flowlabel;
} ip6_u;
......
......@@ -334,8 +334,7 @@ extern void ip6_flush_pending_frames(struct sock *sk);
extern int ip6_dst_lookup(struct sock *sk,
struct dst_entry **dst,
struct flowi *fl,
struct in6_addr **saddr);
struct flowi *fl);
/*
* skb processing functions
......
......@@ -315,14 +315,14 @@ static inline u32 __flow_hash4(struct flowi *fl)
static inline u32 __flow_hash6(struct flowi *fl)
{
u32 hash = fl->fl6_src->s6_addr32[2] ^
fl->fl6_src->s6_addr32[3] ^
u32 hash = fl->fl6_src.s6_addr32[2] ^
fl->fl6_src.s6_addr32[3] ^
fl->fl_ip_sport;
hash = ((hash & 0xF0F0F0F0) >> 4) | ((hash & 0x0F0F0F0F) << 4);
hash ^= fl->fl6_dst->s6_addr32[2] ^
fl->fl6_dst->s6_addr32[3] ^
hash ^= fl->fl6_dst.s6_addr32[2] ^
fl->fl6_dst.s6_addr32[3] ^
fl->fl_ip_dport;
hash ^= (hash >> 10);
hash ^= (hash >> 20);
......@@ -471,8 +471,8 @@ __xfrm4_selector_match(struct xfrm_selector *sel, struct flowi *fl)
static inline int
__xfrm6_selector_match(struct xfrm_selector *sel, struct flowi *fl)
{
return addr_match(fl->fl6_dst, &sel->daddr, sel->prefixlen_d) &&
addr_match(fl->fl6_src, &sel->saddr, sel->prefixlen_s) &&
return addr_match(&fl->fl6_dst, &sel->daddr, sel->prefixlen_d) &&
addr_match(&fl->fl6_src, &sel->saddr, sel->prefixlen_s) &&
!((fl->fl_ip_dport^sel->dport)&sel->dport_mask) &&
!((fl->fl_ip_sport^sel->sport)&sel->sport_mask) &&
(fl->proto == sel->proto || !sel->proto) &&
......@@ -654,7 +654,7 @@ xfrm_address_t *xfrm_flowi_daddr(struct flowi *fl, unsigned short family)
case AF_INET:
return (xfrm_address_t *)&fl->fl4_dst;
case AF_INET6:
return (xfrm_address_t *)fl->fl6_dst;
return (xfrm_address_t *)&fl->fl6_dst;
}
return NULL;
}
......@@ -666,7 +666,7 @@ xfrm_address_t *xfrm_flowi_saddr(struct flowi *fl, unsigned short family)
case AF_INET:
return (xfrm_address_t *)&fl->fl4_src;
case AF_INET6:
return (xfrm_address_t *)fl->fl6_src;
return (xfrm_address_t *)&fl->fl6_src;
}
return NULL;
}
......
......@@ -125,13 +125,6 @@ config IP_ROUTE_VERBOSE
handled by the klogd daemon which is responsible for kernel messages
("man klogd").
config IP_ROUTE_LARGE_TABLES
bool "IP: large routing tables"
depends on IP_ADVANCED_ROUTER
help
If you have routing zones that grow to more than about 64 entries,
you may want to say Y here to speed up the routing process.
config IP_PNP
bool "IP: kernel level autoconfiguration"
depends on INET
......
......@@ -578,7 +578,7 @@ int __init esp4_init(void)
decap_data_too_small();
}
SET_MODULE_OWNER(&esp_type);
esp_type.owner = THIS_MODULE;
if (xfrm_register_type(&esp_type, AF_INET) < 0) {
printk(KERN_INFO "ip esp init: can't add xfrm type\n");
return -EAGAIN;
......
......@@ -89,7 +89,7 @@ struct fn_zone
int fz_nent; /* Number of entries */
int fz_divisor; /* Hash divisor */
u32 fz_hashmask; /* (1<<fz_divisor) - 1 */
u32 fz_hashmask; /* (fz_divisor - 1) */
#define FZ_HASHMASK(fz) ((fz)->fz_hashmask)
int fz_order; /* Zone order */
......@@ -149,9 +149,30 @@ static __inline__ int fn_key_leq(fn_key_t a, fn_key_t b)
static rwlock_t fib_hash_lock = RW_LOCK_UNLOCKED;
#define FZ_MAX_DIVISOR 1024
#define FZ_MAX_DIVISOR ((PAGE_SIZE<<MAX_ORDER) / sizeof(struct fib_node *))
#ifdef CONFIG_IP_ROUTE_LARGE_TABLES
static unsigned long size_to_order(unsigned long size)
{
unsigned long order;
for (order = 0; order < MAX_ORDER; order++) {
if ((PAGE_SIZE << order) >= size)
break;
}
return order;
}
static struct fib_node **fz_hash_alloc(int divisor)
{
unsigned long size = divisor * sizeof(struct fib_node *);
if (divisor <= 1024) {
return kmalloc(size, GFP_KERNEL);
} else {
return (struct fib_node **)
__get_free_pages(GFP_KERNEL, size_to_order(size));
}
}
/* The fib hash lock must be held when this is called. */
static __inline__ void fn_rebuild_zone(struct fn_zone *fz,
......@@ -174,6 +195,15 @@ static __inline__ void fn_rebuild_zone(struct fn_zone *fz,
}
}
static void fz_hash_free(struct fib_node **hash, int divisor)
{
if (divisor <= 1024)
kfree(hash);
else
free_pages((unsigned long) hash,
size_to_order(divisor * sizeof(struct fib_node *)));
}
static void fn_rehash_zone(struct fn_zone *fz)
{
struct fib_node **ht, **old_ht;
......@@ -185,24 +215,30 @@ static void fn_rehash_zone(struct fn_zone *fz)
switch (old_divisor) {
case 16:
new_divisor = 256;
new_hashmask = 0xFF;
break;
case 256:
new_divisor = 1024;
new_hashmask = 0x3FF;
break;
default:
printk(KERN_CRIT "route.c: bad divisor %d!\n", old_divisor);
return;
if ((old_divisor << 1) > FZ_MAX_DIVISOR) {
printk(KERN_CRIT "route.c: bad divisor %d!\n", old_divisor);
return;
}
new_divisor = (old_divisor << 1);
break;
}
new_hashmask = (new_divisor - 1);
#if RT_CACHE_DEBUG >= 2
printk("fn_rehash_zone: hash for zone %d grows from %d\n", fz->fz_order, old_divisor);
#endif
ht = kmalloc(new_divisor*sizeof(struct fib_node*), GFP_KERNEL);
ht = fz_hash_alloc(new_divisor);
if (ht) {
memset(ht, 0, new_divisor*sizeof(struct fib_node*));
write_lock_bh(&fib_hash_lock);
old_ht = fz->fz_hash;
fz->fz_hash = ht;
......@@ -210,10 +246,10 @@ static void fn_rehash_zone(struct fn_zone *fz)
fz->fz_divisor = new_divisor;
fn_rebuild_zone(fz, old_ht, old_divisor);
write_unlock_bh(&fib_hash_lock);
kfree(old_ht);
fz_hash_free(old_ht, old_divisor);
}
}
#endif /* CONFIG_IP_ROUTE_LARGE_TABLES */
static void fn_free_node(struct fib_node * f)
{
......@@ -233,12 +269,11 @@ fn_new_zone(struct fn_hash *table, int z)
memset(fz, 0, sizeof(struct fn_zone));
if (z) {
fz->fz_divisor = 16;
fz->fz_hashmask = 0xF;
} else {
fz->fz_divisor = 1;
fz->fz_hashmask = 0;
}
fz->fz_hash = kmalloc(fz->fz_divisor*sizeof(struct fib_node*), GFP_KERNEL);
fz->fz_hashmask = (fz->fz_divisor - 1);
fz->fz_hash = fz_hash_alloc(fz->fz_divisor);
if (!fz->fz_hash) {
kfree(fz);
return NULL;
......@@ -467,12 +502,10 @@ rta->rta_prefsrc ? *(u32*)rta->rta_prefsrc : 0);
if ((fi = fib_create_info(r, rta, n, &err)) == NULL)
return err;
#ifdef CONFIG_IP_ROUTE_LARGE_TABLES
if (fz->fz_nent > (fz->fz_divisor<<2) &&
if (fz->fz_nent > (fz->fz_divisor<<1) &&
fz->fz_divisor < FZ_MAX_DIVISOR &&
(z==32 || (1<<z) > fz->fz_divisor))
fn_rehash_zone(fz);
#endif
fp = fz_chain_p(key, fz);
......
......@@ -400,7 +400,7 @@ static struct inet_protocol ipcomp4_protocol = {
static int __init ipcomp4_init(void)
{
SET_MODULE_OWNER(&ipcomp_type);
ipcomp_type.owner = THIS_MODULE;
if (xfrm_register_type(&ipcomp_type, AF_INET) < 0) {
printk(KERN_INFO "ipcomp init: can't add xfrm type\n");
return -EAGAIN;
......
......@@ -1391,8 +1391,11 @@ static void *udp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
sk = v;
sk = sk->next;
if (sk)
goto out;
for (; sk; sk = sk->next) {
if (sk->family == AF_INET)
goto out;
}
state = seq->private;
if (++state->bucket >= UDP_HTABLE_SIZE)
......
......@@ -229,7 +229,7 @@ static struct inet_protocol ipip_protocol = {
static int __init ipip_init(void)
{
SET_MODULE_OWNER(&ipip_type);
ipip_type.owner = THIS_MODULE;
if (xfrm_register_type(&ipip_type, AF_INET) < 0) {
printk(KERN_INFO "ipip init: can't add xfrm type\n");
return -EAGAIN;
......
......@@ -77,11 +77,13 @@ MODULE_LICENSE("GPL");
extern int raw6_proc_init(void);
extern int raw6_proc_exit(void);
extern int anycast6_get_info(char *, char **, off_t, int);
extern int tcp6_get_info(char *, char **, off_t, int);
extern int udp6_get_info(char *, char **, off_t, int);
extern int afinet6_get_info(char *, char **, off_t, int);
extern int afinet6_get_snmp(char *, char **, off_t, int);
extern int ipv6_misc_proc_init(void);
extern int ipv6_misc_proc_exit(void);
extern int anycast6_get_info(char *, char **, off_t, int);
#endif
#ifdef CONFIG_SYSCTL
......@@ -816,9 +818,7 @@ static int __init inet6_init(void)
#ifdef CONFIG_PROC_FS
proc_anycast6_fail:
proc_net_remove("snmp6");
proc_net_remove("dev_snmp6");
proc_net_remove("sockstat6");
ipv6_misc_proc_exit();
proc_misc6_fail:
proc_net_remove("udp6");
proc_udp6_fail:
......@@ -852,9 +852,7 @@ static void inet6_exit(void)
raw6_proc_exit();
proc_net_remove("tcp6");
proc_net_remove("udp6");
proc_net_remove("sockstat6");
proc_net_remove("dev_snmp6");
proc_net_remove("snmp6");
ipv6_misc_proc_exit();
proc_net_remove("anycast6");
#endif
/* Cleanup code parts. */
......
......@@ -80,7 +80,7 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info)
iph = (struct ipv6hdr*)skb_put(skb, sizeof(struct ipv6hdr));
skb->nh.ipv6h = iph;
ipv6_addr_copy(&iph->daddr, fl->fl6_dst);
ipv6_addr_copy(&iph->daddr, &fl->fl6_dst);
serr = SKB_EXT_ERR(skb);
serr->ee.ee_errno = err;
......@@ -297,7 +297,8 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
goto exit_f;
}
fl->fl6_src = &src_info->ipi6_addr;
ipv6_addr_copy(&fl->fl6_src,
&src_info->ipi6_addr);
}
break;
......
......@@ -223,9 +223,10 @@ int icmpv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct icmp6hd
if (skb_queue_len(&sk->write_queue) == 1) {
skb->csum = csum_partial((char *)icmp6h,
sizeof(struct icmp6hdr), skb->csum);
icmp6h->icmp6_cksum = csum_ipv6_magic(fl->fl6_src,
fl->fl6_dst,
len, fl->proto, skb->csum);
icmp6h->icmp6_cksum = csum_ipv6_magic(&fl->fl6_src,
&fl->fl6_dst,
len, fl->proto,
skb->csum);
} else {
u32 tmp_csum = 0;
......@@ -235,8 +236,8 @@ int icmpv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct icmp6hd
tmp_csum = csum_partial((char *)icmp6h,
sizeof(struct icmp6hdr), tmp_csum);
tmp_csum = csum_ipv6_magic(fl->fl6_src,
fl->fl6_dst,
tmp_csum = csum_ipv6_magic(&fl->fl6_src,
&fl->fl6_dst,
len, fl->proto, tmp_csum);
icmp6h->icmp6_cksum = tmp_csum;
}
......@@ -266,7 +267,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
struct ipv6hdr *hdr = skb->nh.ipv6h;
struct sock *sk = icmpv6_socket->sk;
struct ipv6_pinfo *np = inet6_sk(sk);
struct in6_addr *saddr = NULL, *tmp_saddr = NULL;
struct in6_addr *saddr = NULL;
struct dst_entry *dst;
struct icmp6hdr tmp_hdr;
struct flowi fl;
......@@ -332,11 +333,12 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
return;
}
memset(&fl, 0, sizeof(fl));
fl.proto = IPPROTO_ICMPV6;
fl.fl6_dst = &hdr->saddr;
fl.fl6_src = saddr;
ipv6_addr_copy(&fl.fl6_dst, &hdr->saddr);
if (saddr)
ipv6_addr_copy(&fl.fl6_src, saddr);
fl.oif = iif;
fl.fl6_flowlabel = 0;
fl.fl_icmp_type = type;
fl.fl_icmp_code = code;
......@@ -350,14 +352,14 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
tmp_hdr.icmp6_cksum = 0;
tmp_hdr.icmp6_pointer = htonl(info);
if (!fl.oif && ipv6_addr_is_multicast(fl.fl6_dst))
if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst))
fl.oif = np->mcast_oif;
err = ip6_dst_lookup(sk, &dst, &fl, &tmp_saddr);
err = ip6_dst_lookup(sk, &dst, &fl);
if (err) goto out;
if (hlimit < 0) {
if (ipv6_addr_is_multicast(fl.fl6_dst))
if (ipv6_addr_is_multicast(&fl.fl6_dst))
hlimit = np->mcast_hops;
else
hlimit = np->hop_limit;
......@@ -394,7 +396,6 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
if (likely(idev != NULL))
in6_dev_put(idev);
out:
if (tmp_saddr) kfree(tmp_saddr);
icmpv6_xmit_unlock();
}
......@@ -403,7 +404,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
struct sock *sk = icmpv6_socket->sk;
struct inet6_dev *idev;
struct ipv6_pinfo *np = inet6_sk(sk);
struct in6_addr *saddr = NULL, *tmp_saddr = NULL;
struct in6_addr *saddr = NULL;
struct icmp6hdr *icmph = (struct icmp6hdr *) skb->h.raw;
struct icmp6hdr tmp_hdr;
struct flowi fl;
......@@ -420,25 +421,25 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
memcpy(&tmp_hdr, icmph, sizeof(tmp_hdr));
tmp_hdr.icmp6_type = ICMPV6_ECHO_REPLY;
memset(&fl, 0, sizeof(fl));
fl.proto = IPPROTO_ICMPV6;
fl.fl6_dst = &skb->nh.ipv6h->saddr;
fl.fl6_src = saddr;
ipv6_addr_copy(&fl.fl6_dst, &skb->nh.ipv6h->saddr);
if (saddr)
ipv6_addr_copy(&fl.fl6_src, saddr);
fl.oif = skb->dev->ifindex;
fl.fl6_flowlabel = 0;
fl.fl_icmp_type = ICMPV6_ECHO_REPLY;
fl.fl_icmp_code = 0;
icmpv6_xmit_lock();
if (!fl.oif && ipv6_addr_is_multicast(fl.nl_u.ip6_u.daddr))
if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst))
fl.oif = np->mcast_oif;
err = ip6_dst_lookup(sk, &dst, &fl, &tmp_saddr);
err = ip6_dst_lookup(sk, &dst, &fl);
if (err) goto out;
if (hlimit < 0) {
if (ipv6_addr_is_multicast(fl.fl6_dst))
if (ipv6_addr_is_multicast(&fl.fl6_dst))
hlimit = np->mcast_hops;
else
hlimit = np->hop_limit;
......@@ -464,7 +465,6 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
if (likely(idev != NULL))
in6_dev_put(idev);
out:
if (tmp_saddr) kfree(tmp_saddr);
icmpv6_xmit_unlock();
}
......
......@@ -152,15 +152,14 @@ int ip6_route_me_harder(struct sk_buff *skb)
{
struct ipv6hdr *iph = skb->nh.ipv6h;
struct dst_entry *dst;
struct flowi fl;
fl.proto = iph->nexthdr;
fl.fl6_dst = &iph->daddr;
fl.fl6_src = &iph->saddr;
fl.oif = skb->sk ? skb->sk->bound_dev_if : 0;
fl.fl6_flowlabel = 0;
fl.fl_ip_dport = 0;
fl.fl_ip_sport = 0;
struct flowi fl = {
.oif = skb->sk ? skb->sk->bound_dev_if : 0,
.nl_u =
{ .ip6_u =
{ .daddr = iph->daddr,
.saddr = iph->saddr, } },
.proto = iph->nexthdr,
};
dst = ip6_route_output(skb->sk, &fl);
......@@ -200,7 +199,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
struct ipv6_txoptions *opt)
{
struct ipv6_pinfo *np = sk ? inet6_sk(sk) : NULL;
struct in6_addr *first_hop = fl->fl6_dst;
struct in6_addr *first_hop = &fl->fl6_dst;
struct dst_entry *dst = skb->dst;
struct ipv6hdr *hdr;
u8 proto = fl->proto;
......@@ -255,7 +254,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
hdr->nexthdr = proto;
hdr->hop_limit = hlimit;
ipv6_addr_copy(&hdr->saddr, fl->fl6_src);
ipv6_addr_copy(&hdr->saddr, &fl->fl6_src);
ipv6_addr_copy(&hdr->daddr, first_hop);
mtu = dst_pmtu(dst);
......@@ -320,8 +319,8 @@ static struct ipv6hdr * ip6_bld_1(struct sock *sk, struct sk_buff *skb, struct f
hdr->hop_limit = hlimit;
hdr->nexthdr = fl->proto;
ipv6_addr_copy(&hdr->saddr, fl->fl6_src);
ipv6_addr_copy(&hdr->daddr, fl->fl6_dst);
ipv6_addr_copy(&hdr->saddr, &fl->fl6_src);
ipv6_addr_copy(&hdr->daddr, &fl->fl6_dst);
return hdr;
}
......@@ -526,19 +525,19 @@ int ip6_build_xmit(struct sock *sk, inet_getfrag_t getfrag, const void *data,
{
struct inet_opt *inet = inet_sk(sk);
struct ipv6_pinfo *np = inet6_sk(sk);
struct in6_addr *final_dst = NULL;
struct in6_addr final_dst_buf, *final_dst = NULL;
struct dst_entry *dst;
int err = 0;
unsigned int pktlength, jumbolen, mtu;
struct in6_addr saddr;
if (opt && opt->srcrt) {
struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt;
final_dst = fl->fl6_dst;
fl->fl6_dst = rt0->addr;
ipv6_addr_copy(&final_dst_buf, &fl->fl6_dst);
final_dst = &final_dst_buf;
ipv6_addr_copy(&fl->fl6_dst, rt0->addr);
}
if (!fl->oif && ipv6_addr_is_multicast(fl->fl6_dst))
if (!fl->oif && ipv6_addr_is_multicast(&fl->fl6_dst))
fl->oif = np->mcast_oif;
dst = __sk_dst_check(sk, np->dst_cookie);
......@@ -564,9 +563,9 @@ int ip6_build_xmit(struct sock *sk, inet_getfrag_t getfrag, const void *data,
*/
if (((rt->rt6i_dst.plen != 128 ||
ipv6_addr_cmp(fl->fl6_dst, &rt->rt6i_dst.addr))
ipv6_addr_cmp(&fl->fl6_dst, &rt->rt6i_dst.addr))
&& (np->daddr_cache == NULL ||
ipv6_addr_cmp(fl->fl6_dst, np->daddr_cache)))
ipv6_addr_cmp(&fl->fl6_dst, np->daddr_cache)))
|| (fl->oif && fl->oif != dst->dev->ifindex)) {
dst = NULL;
} else
......@@ -582,8 +581,8 @@ int ip6_build_xmit(struct sock *sk, inet_getfrag_t getfrag, const void *data,
return -ENETUNREACH;
}
if (fl->fl6_src == NULL) {
err = ipv6_get_saddr(dst, fl->fl6_dst, &saddr);
if (ipv6_addr_any(&fl->fl6_src)) {
err = ipv6_get_saddr(dst, &fl->fl6_dst, &fl->fl6_src);
if (err) {
#if IP6_DEBUG >= 2
......@@ -592,7 +591,6 @@ int ip6_build_xmit(struct sock *sk, inet_getfrag_t getfrag, const void *data,
#endif
goto out;
}
fl->fl6_src = &saddr;
}
pktlength = length;
......@@ -604,7 +602,7 @@ int ip6_build_xmit(struct sock *sk, inet_getfrag_t getfrag, const void *data,
}
if (hlimit < 0) {
if (ipv6_addr_is_multicast(fl->fl6_dst))
if (ipv6_addr_is_multicast(&fl->fl6_dst))
hlimit = np->mcast_hops;
else
hlimit = np->hop_limit;
......@@ -715,7 +713,9 @@ int ip6_build_xmit(struct sock *sk, inet_getfrag_t getfrag, const void *data,
* cleanup
*/
out:
ip6_dst_store(sk, dst, fl->fl6_dst == &np->daddr ? &np->daddr : NULL);
ip6_dst_store(sk, dst,
!ipv6_addr_cmp(&fl->fl6_dst, &np->daddr) ?
&np->daddr : NULL);
if (err > 0)
err = np->recverr ? net_xmit_errno(err) : 0;
return err;
......@@ -1135,7 +1135,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
return err;
}
int ip6_dst_lookup(struct sock *sk, struct dst_entry **dst, struct flowi *fl, struct in6_addr **saddr)
int ip6_dst_lookup(struct sock *sk, struct dst_entry **dst, struct flowi *fl)
{
struct ipv6_pinfo *np = inet6_sk(sk);
int err = 0;
......@@ -1163,9 +1163,9 @@ int ip6_dst_lookup(struct sock *sk, struct dst_entry **dst, struct flowi *fl, st
*/
if (((rt->rt6i_dst.plen != 128 ||
ipv6_addr_cmp(fl->fl6_dst, &rt->rt6i_dst.addr))
ipv6_addr_cmp(&fl->fl6_dst, &rt->rt6i_dst.addr))
&& (np->daddr_cache == NULL ||
ipv6_addr_cmp(fl->fl6_dst, np->daddr_cache)))
ipv6_addr_cmp(&fl->fl6_dst, np->daddr_cache)))
|| (fl->oif && fl->oif != (*dst)->dev->ifindex)) {
*dst = NULL;
} else
......@@ -1181,9 +1181,8 @@ int ip6_dst_lookup(struct sock *sk, struct dst_entry **dst, struct flowi *fl, st
return -ENETUNREACH;
}
if (fl->fl6_src == NULL) {
*saddr = kmalloc(sizeof(struct in6_addr), GFP_ATOMIC);
err = ipv6_get_saddr(*dst, fl->fl6_dst, *saddr);
if (ipv6_addr_any(&fl->fl6_src)) {
err = ipv6_get_saddr(*dst, &fl->fl6_dst, &fl->fl6_src);
if (err) {
#if IP6_DEBUG >= 2
......@@ -1192,7 +1191,6 @@ int ip6_dst_lookup(struct sock *sk, struct dst_entry **dst, struct flowi *fl, st
#endif
return err;
}
fl->fl6_src = *saddr;
}
if (*dst) {
......@@ -1415,7 +1413,7 @@ int ip6_push_pending_frames(struct sock *sk)
{
struct sk_buff *skb, *tmp_skb;
struct sk_buff **tail_skb;
struct in6_addr *final_dst = NULL;
struct in6_addr final_dst_buf, *final_dst = &final_dst_buf;
struct inet_opt *inet = inet_sk(sk);
struct ipv6_pinfo *np = inet6_sk(sk);
struct ipv6hdr *hdr;
......@@ -1446,7 +1444,7 @@ int ip6_push_pending_frames(struct sock *sk)
#endif
}
final_dst = fl->fl6_dst;
ipv6_addr_copy(final_dst, &fl->fl6_dst);
__skb_pull(skb, skb->h.raw - skb->nh.raw);
if (opt && opt->opt_flen)
ipv6_push_frag_opts(skb, opt, &proto);
......@@ -1463,7 +1461,7 @@ int ip6_push_pending_frames(struct sock *sk)
hdr->payload_len = 0;
hdr->hop_limit = np->hop_limit;
hdr->nexthdr = proto;
ipv6_addr_copy(&hdr->saddr, fl->fl6_src);
ipv6_addr_copy(&hdr->saddr, &fl->fl6_src);
ipv6_addr_copy(&hdr->daddr, final_dst);
skb->dst = dst_clone(&rt->u.dst);
......
......@@ -405,8 +405,8 @@ static inline void ndisc_flow_init(struct flowi *fl, u8 type,
struct in6_addr *saddr, struct in6_addr *daddr)
{
memset(fl, 0, sizeof(*fl));
fl->fl6_src = saddr;
fl->fl6_dst = daddr;
ipv6_addr_copy(&fl->fl6_src, saddr);
ipv6_addr_copy(&fl->fl6_dst, daddr);
fl->proto = IPPROTO_ICMPV6;
fl->fl_icmp_type = type;
fl->fl_icmp_code = 0;
......
......@@ -291,10 +291,19 @@ int __init ipv6_misc_proc_init(void)
return rc;
proc_sockstat6_fail:
remove_proc_entry("dev_snmp6", proc_net);
proc_net_remove("dev_snmp6");
proc_dev_snmp6_fail:
remove_proc_entry("snmp6", proc_net);
proc_net_remove("snmp6");
proc_snmp6_fail:
rc = -ENOMEM;
goto out;
}
int ipv6_misc_proc_exit(void)
{
proc_net_remove("sockstat6");
proc_net_remove("dev_snmp6");
proc_net_remove("snmp6");
return 0;
}
......@@ -461,9 +461,9 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct r
* Only one fragment on the socket.
*/
/* should be check HW csum miyazawa */
*csum = csum_ipv6_magic(fl->fl6_src,
fl->fl6_dst,
len, fl->proto, skb->csum);
*csum = csum_ipv6_magic(&fl->fl6_src,
&fl->fl6_dst,
len, fl->proto, skb->csum);
} else {
u32 tmp_csum = 0;
......@@ -471,9 +471,9 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct r
tmp_csum = csum_add(tmp_csum, skb->csum);
}
tmp_csum = csum_ipv6_magic(fl->fl6_src,
fl->fl6_dst,
len, fl->proto, tmp_csum);
tmp_csum = csum_ipv6_magic(&fl->fl6_src,
&fl->fl6_dst,
len, fl->proto, tmp_csum);
*csum = tmp_csum;
}
if (*csum == 0)
......@@ -540,7 +540,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
{
struct ipv6_txoptions opt_space;
struct sockaddr_in6 * sin6 = (struct sockaddr_in6 *) msg->msg_name;
struct in6_addr *daddr, *saddr = NULL;
struct in6_addr *daddr;
struct inet_opt *inet = inet_sk(sk);
struct ipv6_pinfo *np = inet6_sk(sk);
struct raw6_opt *raw_opt = raw6_sk(sk);
......@@ -566,9 +566,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
/*
* Get and verify the address.
*/
fl.fl6_flowlabel = 0;
fl.oif = 0;
memset(&fl, 0, sizeof(fl));
if (sin6) {
if (addr_len < SIN6_LEN_RFC2133)
......@@ -628,7 +626,6 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
if (fl.oif == 0)
fl.oif = sk->bound_dev_if;
fl.fl6_src = NULL;
if (msg->msg_controllen) {
opt = &opt_space;
......@@ -653,26 +650,25 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
opt = fl6_merge_options(&opt_space, flowlabel, opt);
fl.proto = proto;
fl.fl6_dst = daddr;
if (fl.fl6_src == NULL && !ipv6_addr_any(&np->saddr))
fl.fl6_src = &np->saddr;
fl.fl_icmp_type = 0;
fl.fl_icmp_code = 0;
ipv6_addr_copy(&fl.fl6_dst, daddr);
if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))
ipv6_addr_copy(&fl.fl6_src, &np->saddr);
/* merge ip6_build_xmit from ip6_output */
if (opt && opt->srcrt) {
struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt;
fl.fl6_dst = rt0->addr;
ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
}
if (!fl.oif && ipv6_addr_is_multicast(fl.nl_u.ip6_u.daddr))
if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst))
fl.oif = np->mcast_oif;
err = ip6_dst_lookup(sk, &dst, &fl, &saddr);
if (err) goto out;
err = ip6_dst_lookup(sk, &dst, &fl);
if (err)
goto out;
if (hlimit < 0) {
if (ipv6_addr_is_multicast(fl.fl6_dst))
if (ipv6_addr_is_multicast(&fl.fl6_dst))
hlimit = np->mcast_hops;
else
hlimit = np->hop_limit;
......@@ -702,14 +698,15 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
}
}
done:
ip6_dst_store(sk, dst, fl.nl_u.ip6_u.daddr == &np->daddr ? &np->daddr : NULL);
ip6_dst_store(sk, dst,
!ipv6_addr_cmp(&fl.fl6_dst, &np->daddr) ?
&np->daddr : NULL);
if (err > 0)
err = np->recverr ? net_xmit_errno(err) : 0;
release_sock(sk);
out:
fl6_sock_release(flowlabel);
if (saddr) kfree(saddr);
return err<0?err:len;
do_confirm:
dst_confirm(dst);
......@@ -1061,6 +1058,6 @@ int __init raw6_proc_init(void)
void raw6_proc_exit(void)
{
remove_proc_entry("raw6", proc_net);
proc_net_remove("raw6");
}
#endif /* CONFIG_PROC_FS */
......@@ -454,12 +454,12 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl)
int strict;
int attempts = 3;
strict = ipv6_addr_type(fl->fl6_dst) & (IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL);
strict = ipv6_addr_type(&fl->fl6_dst) & (IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL);
relookup:
read_lock_bh(&rt6_lock);
fn = fib6_lookup(&ip6_routing_table, fl->fl6_dst, fl->fl6_src);
fn = fib6_lookup(&ip6_routing_table, &fl->fl6_dst, &fl->fl6_src);
restart:
rt = fn->leaf;
......@@ -481,7 +481,7 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl)
if (!rt->rt6i_nexthop && !(rt->rt6i_flags & RTF_NONEXTHOP)) {
read_unlock_bh(&rt6_lock);
rt = rt6_cow(rt, fl->fl6_dst, fl->fl6_src);
rt = rt6_cow(rt, &fl->fl6_dst, &fl->fl6_src);
if (rt->u.dst.error != -EEXIST || --attempts <= 0)
goto out2;
......@@ -1616,9 +1616,11 @@ int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
memset(&fl, 0, sizeof(fl));
if (rta[RTA_SRC-1])
fl.fl6_src = (struct in6_addr*)RTA_DATA(rta[RTA_SRC-1]);
ipv6_addr_copy(&fl.fl6_src,
(struct in6_addr*)RTA_DATA(rta[RTA_SRC-1]));
if (rta[RTA_DST-1])
fl.fl6_dst = (struct in6_addr*)RTA_DATA(rta[RTA_DST-1]);
ipv6_addr_copy(&fl.fl6_dst,
(struct in6_addr*)RTA_DATA(rta[RTA_DST-1]));
if (rta[RTA_IIF-1])
memcpy(&iif, RTA_DATA(rta[RTA_IIF-1]), sizeof(int));
......@@ -1642,7 +1644,7 @@ int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
NETLINK_CB(skb).dst_pid = NETLINK_CB(in_skb).pid;
err = rt6_fill_node(skb, rt,
fl.fl6_dst, fl.fl6_src,
&fl.fl6_dst, &fl.fl6_src,
iif,
RTM_NEWROUTE, NETLINK_CB(in_skb).pid,
nlh->nlmsg_seq, nlh);
......@@ -1929,7 +1931,7 @@ void ip6_route_cleanup(void)
{
#ifdef CONFIG_PROC_FS
proc_net_remove("ipv6_route");
remove_proc_entry("rt6_stats", proc_net);
proc_net_remove("rt6_stats");
#endif
xfrm6_fini();
rt6_ifdown(NULL);
......
......@@ -571,7 +571,8 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
if (usin->sin6_family != AF_INET6)
return(-EAFNOSUPPORT);
fl.fl6_flowlabel = 0;
memset(&fl, 0, sizeof(fl));
if (np->sndflow) {
fl.fl6_flowlabel = usin->sin6_flowinfo&IPV6_FLOWINFO_MASK;
IP6_ECN_flow_init(fl.fl6_flowlabel);
......@@ -666,20 +667,18 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
saddr = &np->rcv_saddr;
fl.proto = IPPROTO_TCP;
fl.fl6_dst = &np->daddr;
fl.fl6_src = saddr;
ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
ipv6_addr_copy(&fl.fl6_src,
(saddr ? saddr : &np->saddr));
fl.oif = sk->bound_dev_if;
fl.fl_ip_dport = usin->sin6_port;
fl.fl_ip_sport = inet->sport;
if (np->opt && np->opt->srcrt) {
struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt;
fl.fl6_dst = rt0->addr;
ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
}
if (!fl.fl6_src)
fl.fl6_src = &np->saddr;
dst = ip6_route_output(sk, &fl);
if ((err = dst->error) != 0) {
......@@ -794,9 +793,10 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
to handle rthdr case. Ignore this complexity
for now.
*/
memset(&fl, 0, sizeof(fl));
fl.proto = IPPROTO_TCP;
fl.fl6_dst = &np->daddr;
fl.fl6_src = &np->saddr;
ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
ipv6_addr_copy(&fl.fl6_src, &np->saddr);
fl.oif = sk->bound_dev_if;
fl.fl_ip_dport = inet->dport;
fl.fl_ip_sport = inet->sport;
......@@ -879,9 +879,10 @@ static int tcp_v6_send_synack(struct sock *sk, struct open_request *req,
struct flowi fl;
int err = -1;
memset(&fl, 0, sizeof(fl));
fl.proto = IPPROTO_TCP;
fl.fl6_dst = &req->af.v6_req.rmt_addr;
fl.fl6_src = &req->af.v6_req.loc_addr;
ipv6_addr_copy(&fl.fl6_dst, &req->af.v6_req.rmt_addr);
ipv6_addr_copy(&fl.fl6_src, &req->af.v6_req.loc_addr);
fl.fl6_flowlabel = 0;
fl.oif = req->af.v6_req.iif;
fl.fl_ip_dport = req->rmt_port;
......@@ -900,7 +901,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct open_request *req,
if (opt && opt->srcrt) {
struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt;
fl.fl6_dst = rt0->addr;
ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
}
dst = ip6_route_output(sk, &fl);
......@@ -916,7 +917,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct open_request *req,
&req->af.v6_req.loc_addr, &req->af.v6_req.rmt_addr,
csum_partial((char *)th, skb->len, skb->csum));
fl.fl6_dst = &req->af.v6_req.rmt_addr;
ipv6_addr_copy(&fl.fl6_dst, &req->af.v6_req.rmt_addr);
err = ip6_xmit(sk, skb, &fl, opt);
if (err == NET_XMIT_CN)
err = 0;
......@@ -1018,11 +1019,11 @@ static void tcp_v6_send_reset(struct sk_buff *skb)
buff->csum = csum_partial((char *)t1, sizeof(*t1), 0);
fl.fl6_dst = &skb->nh.ipv6h->saddr;
fl.fl6_src = &skb->nh.ipv6h->daddr;
fl.fl6_flowlabel = 0;
memset(&fl, 0, sizeof(fl));
ipv6_addr_copy(&fl.fl6_dst, &skb->nh.ipv6h->saddr);
ipv6_addr_copy(&fl.fl6_src, &skb->nh.ipv6h->daddr);
t1->check = csum_ipv6_magic(fl.fl6_src, fl.fl6_dst,
t1->check = csum_ipv6_magic(&fl.fl6_src, &fl.fl6_dst,
sizeof(*t1), IPPROTO_TCP,
buff->csum);
......@@ -1082,11 +1083,11 @@ static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32
buff->csum = csum_partial((char *)t1, tot_len, 0);
fl.fl6_dst = &skb->nh.ipv6h->saddr;
fl.fl6_src = &skb->nh.ipv6h->daddr;
fl.fl6_flowlabel = 0;
memset(&fl, 0, sizeof(fl));
ipv6_addr_copy(&fl.fl6_dst, &skb->nh.ipv6h->saddr);
ipv6_addr_copy(&fl.fl6_src, &skb->nh.ipv6h->daddr);
t1->check = csum_ipv6_magic(fl.fl6_src, fl.fl6_dst,
t1->check = csum_ipv6_magic(&fl.fl6_src, &fl.fl6_dst,
tot_len, IPPROTO_TCP,
buff->csum);
......@@ -1261,7 +1262,6 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
{
struct ipv6_pinfo *newnp, *np = inet6_sk(sk);
struct tcp6_sock *newtcp6sk;
struct flowi fl;
struct inet_opt *newinet;
struct tcp_opt *newtp;
struct sock *newsk;
......@@ -1330,14 +1330,16 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
}
if (dst == NULL) {
struct flowi fl;
memset(&fl, 0, sizeof(fl));
fl.proto = IPPROTO_TCP;
fl.fl6_dst = &req->af.v6_req.rmt_addr;
ipv6_addr_copy(&fl.fl6_dst, &req->af.v6_req.rmt_addr);
if (opt && opt->srcrt) {
struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt;
fl.fl6_dst = rt0->addr;
ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
}
fl.fl6_src = &req->af.v6_req.loc_addr;
fl.fl6_flowlabel = 0;
ipv6_addr_copy(&fl.fl6_src, &req->af.v6_req.loc_addr);
fl.oif = sk->bound_dev_if;
fl.fl_ip_dport = req->rmt_port;
fl.fl_ip_sport = inet_sk(sk)->sport;
......@@ -1725,9 +1727,10 @@ static int tcp_v6_rebuild_header(struct sock *sk)
struct inet_opt *inet = inet_sk(sk);
struct flowi fl;
memset(&fl, 0, sizeof(fl));
fl.proto = IPPROTO_TCP;
fl.fl6_dst = &np->daddr;
fl.fl6_src = &np->saddr;
ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
ipv6_addr_copy(&fl.fl6_src, &np->saddr);
fl.fl6_flowlabel = np->flow_label;
fl.oif = sk->bound_dev_if;
fl.fl_ip_dport = inet->dport;
......@@ -1735,7 +1738,7 @@ static int tcp_v6_rebuild_header(struct sock *sk)
if (np->opt && np->opt->srcrt) {
struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
fl.fl6_dst = rt0->addr;
ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
}
dst = ip6_route_output(sk, &fl);
......@@ -1762,9 +1765,10 @@ static int tcp_v6_xmit(struct sk_buff *skb, int ipfragok)
struct flowi fl;
struct dst_entry *dst;
memset(&fl, 0, sizeof(fl));
fl.proto = IPPROTO_TCP;
fl.fl6_dst = &np->daddr;
fl.fl6_src = &np->saddr;
ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
ipv6_addr_copy(&fl.fl6_src, &np->saddr);
fl.fl6_flowlabel = np->flow_label;
IP6_ECN_flow_xmit(sk, fl.fl6_flowlabel);
fl.oif = sk->bound_dev_if;
......@@ -1773,7 +1777,7 @@ static int tcp_v6_xmit(struct sk_buff *skb, int ipfragok)
if (np->opt && np->opt->srcrt) {
struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
fl.fl6_dst = rt0->addr;
ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
}
dst = __sk_dst_check(sk, np->dst_cookie);
......@@ -1793,7 +1797,7 @@ static int tcp_v6_xmit(struct sk_buff *skb, int ipfragok)
skb->dst = dst_clone(dst);
/* Restore final destination back after routing done */
fl.fl6_dst = &np->daddr;
ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
return ip6_xmit(sk, skb, &fl, np->opt);
}
......
......@@ -270,7 +270,7 @@ int udpv6_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
if (usin->sin6_family != AF_INET6)
return -EAFNOSUPPORT;
fl.fl6_flowlabel = 0;
memset(&fl, 0, sizeof(fl));
if (np->sndflow) {
fl.fl6_flowlabel = usin->sin6_flowinfo&IPV6_FLOWINFO_MASK;
if (fl.fl6_flowlabel&IPV6_FLOWLABEL_MASK) {
......@@ -350,8 +350,8 @@ int udpv6_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
*/
fl.proto = IPPROTO_UDP;
fl.fl6_dst = &np->daddr;
fl.fl6_src = &saddr;
ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
ipv6_addr_copy(&fl.fl6_src, &saddr);
fl.oif = sk->bound_dev_if;
fl.fl_ip_dport = inet->dport;
fl.fl_ip_sport = inet->sport;
......@@ -362,11 +362,11 @@ int udpv6_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
if (flowlabel) {
if (flowlabel->opt && flowlabel->opt->srcrt) {
struct rt0_hdr *rt0 = (struct rt0_hdr *) flowlabel->opt->srcrt;
fl.fl6_dst = rt0->addr;
ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
}
} else if (np->opt && np->opt->srcrt) {
struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt;
fl.fl6_dst = rt0->addr;
ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
}
dst = ip6_route_output(sk, &fl);
......@@ -377,7 +377,7 @@ int udpv6_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
return err;
}
ip6_dst_store(sk, dst, fl.fl6_dst);
ip6_dst_store(sk, dst, &fl.fl6_dst);
/* get the source address used in the appropriate device */
......@@ -784,8 +784,8 @@ static int udp_v6_push_pending_frames(struct sock *sk, struct udp_opt *up)
if (skb_queue_len(&sk->write_queue) == 1) {
skb->csum = csum_partial((char *)uh,
sizeof(struct udphdr), skb->csum);
uh->check = csum_ipv6_magic(fl->fl6_src,
fl->fl6_dst,
uh->check = csum_ipv6_magic(&fl->fl6_src,
&fl->fl6_dst,
up->len, fl->proto, skb->csum);
} else {
u32 tmp_csum = 0;
......@@ -795,8 +795,8 @@ static int udp_v6_push_pending_frames(struct sock *sk, struct udp_opt *up)
}
tmp_csum = csum_partial((char *)uh,
sizeof(struct udphdr), tmp_csum);
tmp_csum = csum_ipv6_magic(fl->fl6_src,
fl->fl6_dst,
tmp_csum = csum_ipv6_magic(&fl->fl6_src,
&fl->fl6_dst,
up->len, fl->proto, tmp_csum);
uh->check = tmp_csum;
......@@ -819,7 +819,7 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
struct inet_opt *inet = inet_sk(sk);
struct ipv6_pinfo *np = inet6_sk(sk);
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) msg->msg_name;
struct in6_addr *daddr, *saddr = NULL;
struct in6_addr *daddr;
struct ipv6_txoptions *opt = NULL;
struct ip6_flowlabel *flowlabel = NULL;
struct flowi fl;
......@@ -849,8 +849,7 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
}
ulen += sizeof(struct udphdr);
fl.fl6_flowlabel = 0;
fl.oif = 0;
memset(&fl, 0, sizeof(fl));
if (sin6) {
if (sin6->sin6_family == AF_INET) {
......@@ -919,7 +918,6 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
if (!fl.oif)
fl.oif = sk->bound_dev_if;
fl.fl6_src = NULL;
if (msg->msg_controllen) {
opt = &opt_space;
......@@ -944,26 +942,27 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
opt = fl6_merge_options(&opt_space, flowlabel, opt);
fl.proto = IPPROTO_UDP;
fl.fl6_dst = daddr;
if (fl.fl6_src == NULL && !ipv6_addr_any(&np->saddr))
fl.fl6_src = &np->saddr;
ipv6_addr_copy(&fl.fl6_dst, daddr);
if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))
ipv6_addr_copy(&fl.fl6_src, &np->saddr);
fl.fl_ip_dport = up->dport;
fl.fl_ip_sport = inet->sport;
/* merge ip6_build_xmit from ip6_output */
if (opt && opt->srcrt) {
struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt;
fl.fl6_dst = rt0->addr;
ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
}
if (!fl.oif && ipv6_addr_is_multicast(fl.nl_u.ip6_u.daddr))
if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst))
fl.oif = np->mcast_oif;
err = ip6_dst_lookup(sk, &dst, &fl, &saddr);
if (err) goto out;
err = ip6_dst_lookup(sk, &dst, &fl);
if (err)
goto out;
if (hlimit < 0) {
if (ipv6_addr_is_multicast(fl.fl6_dst))
if (ipv6_addr_is_multicast(&fl.fl6_dst))
hlimit = np->mcast_hops;
else
hlimit = np->hop_limit;
......@@ -998,13 +997,14 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
else if (!corkreq)
err = udp_v6_push_pending_frames(sk, up);
ip6_dst_store(sk, dst, fl.nl_u.ip6_u.daddr == &np->daddr ? &np->daddr : NULL);
ip6_dst_store(sk, dst,
!ipv6_addr_cmp(&fl.fl6_dst, &np->daddr) ?
&np->daddr : NULL);
if (err > 0)
err = np->recverr ? net_xmit_errno(err) : 0;
release_sock(sk);
out:
fl6_sock_release(flowlabel);
if (saddr) kfree(saddr);
if (!err) {
UDP6_INC_STATS_USER(UdpOutDatagrams);
return len;
......
......@@ -60,8 +60,8 @@ __xfrm6_find_bundle(struct flowi *fl, struct rtable *rt, struct xfrm_policy *pol
read_lock_bh(&policy->lock);
for (dst = policy->bundles; dst; dst = dst->next) {
struct xfrm_dst *xdst = (struct xfrm_dst*)dst;
if (!ipv6_addr_cmp(&xdst->u.rt6.rt6i_dst.addr, fl->fl6_dst) &&
!ipv6_addr_cmp(&xdst->u.rt6.rt6i_src.addr, fl->fl6_src) &&
if (!ipv6_addr_cmp(&xdst->u.rt6.rt6i_dst.addr, &fl->fl6_dst) &&
!ipv6_addr_cmp(&xdst->u.rt6.rt6i_src.addr, &fl->fl6_src) &&
__xfrm6_bundle_ok(xdst, fl)) {
dst_clone(dst);
break;
......@@ -82,8 +82,8 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
struct dst_entry *dst, *dst_prev;
struct rt6_info *rt0 = (struct rt6_info*)(*dst_p);
struct rt6_info *rt = rt0;
struct in6_addr *remote = fl->fl6_dst;
struct in6_addr *local = fl->fl6_src;
struct in6_addr *remote = &fl->fl6_dst;
struct in6_addr *local = &fl->fl6_src;
int i;
int err = 0;
int header_len = 0;
......@@ -116,13 +116,15 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
trailer_len += xfrm[i]->props.trailer_len;
}
if (ipv6_addr_cmp(remote, fl->fl6_dst)) {
struct flowi fl_tunnel = { .nl_u = { .ip6_u =
{ .daddr = remote,
.saddr = local }
}
};
err = xfrm_dst_lookup((struct xfrm_dst**)&rt, &fl_tunnel, AF_INET6);
if (ipv6_addr_cmp(remote, &fl->fl6_dst)) {
struct flowi fl_tunnel;
memset(&fl_tunnel, 0, sizeof(fl_tunnel));
ipv6_addr_copy(&fl_tunnel.fl6_dst, remote);
ipv6_addr_copy(&fl_tunnel.fl6_src, local);
err = xfrm_dst_lookup((struct xfrm_dst **) &rt,
&fl_tunnel, AF_INET6);
if (err)
goto error;
} else {
......@@ -175,8 +177,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl)
struct ipv6_opt_hdr *exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset);
u8 nexthdr = skb->nh.ipv6h->nexthdr;
fl->fl6_dst = &hdr->daddr;
fl->fl6_src = &hdr->saddr;
ipv6_addr_copy(&fl->fl6_dst, &hdr->daddr);
ipv6_addr_copy(&fl->fl6_src, &hdr->saddr);
while (pskb_may_pull(skb, skb->nh.raw + offset + 1 - skb->data)) {
switch (nexthdr) {
......
......@@ -25,8 +25,8 @@ __xfrm6_init_tempsel(struct xfrm_state *x, struct flowi *fl,
{
/* Initialize temporary selector matching only
* to current session. */
ipv6_addr_copy((struct in6_addr *)&x->sel.daddr, fl->fl6_dst);
ipv6_addr_copy((struct in6_addr *)&x->sel.saddr, fl->fl6_src);
ipv6_addr_copy((struct in6_addr *)&x->sel.daddr, &fl->fl6_dst);
ipv6_addr_copy((struct in6_addr *)&x->sel.saddr, &fl->fl6_src);
x->sel.dport = fl->fl_ip_dport;
x->sel.dport_mask = ~0;
x->sel.sport = fl->fl_ip_sport;
......
......@@ -2244,6 +2244,7 @@ static void dump_ah_combs(struct sk_buff *skb, struct xfrm_tmpl *t)
p->sadb_prop_len = sizeof(struct sadb_prop)/8;
p->sadb_prop_exttype = SADB_EXT_PROPOSAL;
p->sadb_prop_replay = 32;
memset(p->sadb_prop_reserved, 0, sizeof(p->sadb_prop_reserved));
for (i = 0; ; i++) {
struct xfrm_algo_desc *aalg = xfrm_aalg_get_byidx(i);
......@@ -2275,6 +2276,7 @@ static void dump_esp_combs(struct sk_buff *skb, struct xfrm_tmpl *t)
p->sadb_prop_len = sizeof(struct sadb_prop)/8;
p->sadb_prop_exttype = SADB_EXT_PROPOSAL;
p->sadb_prop_replay = 32;
memset(p->sadb_prop_reserved, 0, sizeof(p->sadb_prop_reserved));
for (i=0; ; i++) {
struct xfrm_algo_desc *ealg = xfrm_ealg_get_byidx(i);
......
......@@ -144,17 +144,19 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport,
struct ipv6_pinfo *np = inet6_sk(sk);
struct flowi fl;
memset(&fl, 0, sizeof(fl));
fl.proto = sk->protocol;
/* Fill in the dest address from the route entry passed with the skb
* and the source address from the transport.
*/
fl.fl6_dst = &transport->ipaddr.v6.sin6_addr;
fl.fl6_src = &transport->saddr.v6.sin6_addr;
ipv6_addr_copy(&fl.fl6_dst, &transport->ipaddr.v6.sin6_addr);
ipv6_addr_copy(&fl.fl6_src, &transport->saddr.v6.sin6_addr);
fl.fl6_flowlabel = np->flow_label;
IP6_ECN_flow_xmit(sk, fl.fl6_flowlabel);
if (ipv6_addr_type(fl.fl6_src) & IPV6_ADDR_LINKLOCAL)
if (ipv6_addr_type(&fl.fl6_src) & IPV6_ADDR_LINKLOCAL)
fl.oif = transport->saddr.v6.sin6_scope_id;
else
fl.oif = sk->bound_dev_if;
......@@ -163,14 +165,14 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport,
if (np->opt && np->opt->srcrt) {
struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
fl.nl_u.ip6_u.daddr = rt0->addr;
ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
}
SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, "
"src:%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x "
"dst:%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
__FUNCTION__, skb, skb->len,
NIP6(*fl.fl6_src), NIP6(*fl.fl6_dst));
NIP6(fl.fl6_src), NIP6(fl.fl6_dst));
SCTP_INC_STATS(SctpOutSCTPPacks);
......@@ -185,17 +187,19 @@ struct dst_entry *sctp_v6_get_dst(struct sctp_association *asoc,
union sctp_addr *saddr)
{
struct dst_entry *dst;
struct flowi fl = {
.nl_u = { .ip6_u = { .daddr = &daddr->v6.sin6_addr, } } };
struct flowi fl;
memset(&fl, 0, sizeof(fl));
ipv6_addr_copy(&fl.fl6_dst, &daddr->v6.sin6_addr);
SCTP_DEBUG_PRINTK("%s: DST=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x ",
__FUNCTION__, NIP6(*fl.fl6_dst));
__FUNCTION__, NIP6(fl.fl6_dst));
if (saddr) {
fl.fl6_src = &saddr->v6.sin6_addr;
ipv6_addr_copy(&fl.fl6_src, &saddr->v6.sin6_addr);
SCTP_DEBUG_PRINTK(
"SRC=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x - ",
NIP6(*fl.fl6_src));
NIP6(fl.fl6_src));
}
dst = ip6_route_output(NULL, &fl);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment