forked from Minki/linux
[NET] DECNET: Fix whitespace errors.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c9eaf17341
commit
429eb0fae6
@ -63,7 +63,7 @@ Version Kernel Date Author/Comments
|
||||
Version 0.0.1 2.0.30 01-dic-97 Eduardo Marcelo Serrat
|
||||
(emserrat@geocities.com)
|
||||
|
||||
First Development of DECnet Socket La-
|
||||
First Development of DECnet Socket La-
|
||||
yer for Linux. Only supports outgoing
|
||||
connections.
|
||||
|
||||
@ -75,28 +75,28 @@ Version 0.0.2 2.1.105 20-jun-98 Patrick J. Caulfield
|
||||
Version 0.0.3 2.1.106 25-jun-98 Eduardo Marcelo Serrat
|
||||
(emserrat@geocities.com)
|
||||
_
|
||||
Added support for incoming connections
|
||||
so we can start developing server apps
|
||||
on Linux.
|
||||
Added support for incoming connections
|
||||
so we can start developing server apps
|
||||
on Linux.
|
||||
-
|
||||
Module Support
|
||||
Version 0.0.4 2.1.109 21-jul-98 Eduardo Marcelo Serrat
|
||||
(emserrat@geocities.com)
|
||||
_
|
||||
Added support for X11R6.4. Now we can
|
||||
use DECnet transport for X on Linux!!!
|
||||
-
|
||||
(emserrat@geocities.com)
|
||||
_
|
||||
Added support for X11R6.4. Now we can
|
||||
use DECnet transport for X on Linux!!!
|
||||
-
|
||||
Version 0.0.5 2.1.110 01-aug-98 Eduardo Marcelo Serrat
|
||||
(emserrat@geocities.com)
|
||||
Removed bugs on flow control
|
||||
Removed bugs on incoming accessdata
|
||||
order
|
||||
-
|
||||
(emserrat@geocities.com)
|
||||
Removed bugs on flow control
|
||||
Removed bugs on incoming accessdata
|
||||
order
|
||||
-
|
||||
Version 0.0.6 2.1.110 07-aug-98 Eduardo Marcelo Serrat
|
||||
dn_recvmsg fixes
|
||||
dn_recvmsg fixes
|
||||
|
||||
Patrick J. Caulfield
|
||||
dn_bind fixes
|
||||
Patrick J. Caulfield
|
||||
dn_bind fixes
|
||||
*******************************************************************************/
|
||||
|
||||
#include <linux/module.h>
|
||||
@ -400,7 +400,7 @@ struct sock *dn_sklist_find_listener(struct sockaddr_dn *addr)
|
||||
|
||||
sk = sk_head(&dn_wild_sk);
|
||||
if (sk) {
|
||||
if (sk->sk_state == TCP_LISTEN)
|
||||
if (sk->sk_state == TCP_LISTEN)
|
||||
sock_hold(sk);
|
||||
else
|
||||
sk = NULL;
|
||||
@ -500,7 +500,7 @@ static struct sock *dn_alloc_sock(struct socket *sock, gfp_t gfp)
|
||||
scp->ackxmt_oth = 0; /* Last oth data ack'ed */
|
||||
scp->ackrcv_dat = 0; /* Highest data ack recv*/
|
||||
scp->ackrcv_oth = 0; /* Last oth data ack rec*/
|
||||
scp->flowrem_sw = DN_SEND;
|
||||
scp->flowrem_sw = DN_SEND;
|
||||
scp->flowloc_sw = DN_SEND;
|
||||
scp->flowrem_dat = 0;
|
||||
scp->flowrem_oth = 1;
|
||||
@ -713,7 +713,7 @@ dn_release(struct socket *sock)
|
||||
sock_put(sk);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
|
||||
@ -770,7 +770,7 @@ static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
|
||||
}
|
||||
release_sock(sk);
|
||||
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
@ -997,20 +997,20 @@ static inline int dn_check_state(struct sock *sk, struct sockaddr_dn *addr, int
|
||||
|
||||
static void dn_access_copy(struct sk_buff *skb, struct accessdata_dn *acc)
|
||||
{
|
||||
unsigned char *ptr = skb->data;
|
||||
unsigned char *ptr = skb->data;
|
||||
|
||||
acc->acc_userl = *ptr++;
|
||||
memcpy(&acc->acc_user, ptr, acc->acc_userl);
|
||||
ptr += acc->acc_userl;
|
||||
acc->acc_userl = *ptr++;
|
||||
memcpy(&acc->acc_user, ptr, acc->acc_userl);
|
||||
ptr += acc->acc_userl;
|
||||
|
||||
acc->acc_passl = *ptr++;
|
||||
memcpy(&acc->acc_pass, ptr, acc->acc_passl);
|
||||
ptr += acc->acc_passl;
|
||||
acc->acc_passl = *ptr++;
|
||||
memcpy(&acc->acc_pass, ptr, acc->acc_passl);
|
||||
ptr += acc->acc_passl;
|
||||
|
||||
acc->acc_accl = *ptr++;
|
||||
memcpy(&acc->acc_acc, ptr, acc->acc_accl);
|
||||
acc->acc_accl = *ptr++;
|
||||
memcpy(&acc->acc_acc, ptr, acc->acc_accl);
|
||||
|
||||
skb_pull(skb, acc->acc_accl + acc->acc_passl + acc->acc_userl + 3);
|
||||
skb_pull(skb, acc->acc_accl + acc->acc_passl + acc->acc_userl + 3);
|
||||
|
||||
}
|
||||
|
||||
@ -1071,7 +1071,7 @@ static int dn_accept(struct socket *sock, struct socket *newsock, int flags)
|
||||
|
||||
lock_sock(sk);
|
||||
|
||||
if (sk->sk_state != TCP_LISTEN || DN_SK(sk)->state != DN_O) {
|
||||
if (sk->sk_state != TCP_LISTEN || DN_SK(sk)->state != DN_O) {
|
||||
release_sock(sk);
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -1098,7 +1098,7 @@ static int dn_accept(struct socket *sock, struct socket *newsock, int flags)
|
||||
dst_release(xchg(&newsk->sk_dst_cache, skb->dst));
|
||||
skb->dst = NULL;
|
||||
|
||||
DN_SK(newsk)->state = DN_CR;
|
||||
DN_SK(newsk)->state = DN_CR;
|
||||
DN_SK(newsk)->addrrem = cb->src_port;
|
||||
DN_SK(newsk)->services_rem = cb->services;
|
||||
DN_SK(newsk)->info_rem = cb->info;
|
||||
@ -1154,15 +1154,15 @@ static int dn_accept(struct socket *sock, struct socket *newsock, int flags)
|
||||
dn_send_conn_ack(newsk);
|
||||
|
||||
/*
|
||||
* Here we use sk->sk_allocation since although the conn conf is
|
||||
* for the newsk, the context is the old socket.
|
||||
*/
|
||||
* Here we use sk->sk_allocation since although the conn conf is
|
||||
* for the newsk, the context is the old socket.
|
||||
*/
|
||||
if (DN_SK(newsk)->accept_mode == ACC_IMMED)
|
||||
err = dn_confirm_accept(newsk, &timeo,
|
||||
sk->sk_allocation);
|
||||
}
|
||||
release_sock(newsk);
|
||||
return err;
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
@ -1180,7 +1180,7 @@ static int dn_getname(struct socket *sock, struct sockaddr *uaddr,int *uaddr_len
|
||||
if ((sock->state != SS_CONNECTED &&
|
||||
sock->state != SS_CONNECTING) &&
|
||||
scp->accept_mode == ACC_IMMED) {
|
||||
release_sock(sk);
|
||||
release_sock(sk);
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
@ -1191,7 +1191,7 @@ static int dn_getname(struct socket *sock, struct sockaddr *uaddr,int *uaddr_len
|
||||
|
||||
release_sock(sk);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -1285,7 +1285,7 @@ static int dn_listen(struct socket *sock, int backlog)
|
||||
out:
|
||||
release_sock(sk);
|
||||
|
||||
return err;
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
@ -1375,7 +1375,7 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us
|
||||
break;
|
||||
|
||||
case DSO_DISDATA:
|
||||
if (sock->state != SS_CONNECTED && scp->accept_mode == ACC_IMMED)
|
||||
if (sock->state != SS_CONNECTED && scp->accept_mode == ACC_IMMED)
|
||||
return -ENOTCONN;
|
||||
|
||||
if (optlen != sizeof(struct optdata_dn))
|
||||
@ -1588,7 +1588,7 @@ static int __dn_getsockopt(struct socket *sock, int level,int optname, char __us
|
||||
case DSO_SEQPACKET:
|
||||
case DSO_CONACCEPT:
|
||||
case DSO_CONREJECT:
|
||||
return -ENOPROTOOPT;
|
||||
return -ENOPROTOOPT;
|
||||
|
||||
case DSO_MAXWINDOW:
|
||||
if (r_len > sizeof(unsigned long))
|
||||
@ -2214,7 +2214,7 @@ static void dn_printable_object(struct sockaddr_dn *dn, unsigned char *buf)
|
||||
buf[i] = '.';
|
||||
}
|
||||
buf[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static char *dn_state2asc(unsigned char state)
|
||||
@ -2381,7 +2381,7 @@ static int __init decnet_init(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
printk(banner);
|
||||
printk(banner);
|
||||
|
||||
rc = proto_register(&dn_proto, 1);
|
||||
if (rc != 0)
|
||||
|
@ -884,39 +884,39 @@ last_chance:
|
||||
|
||||
static void dn_send_endnode_hello(struct net_device *dev, struct dn_ifaddr *ifa)
|
||||
{
|
||||
struct endnode_hello_message *msg;
|
||||
struct sk_buff *skb = NULL;
|
||||
__le16 *pktlen;
|
||||
struct endnode_hello_message *msg;
|
||||
struct sk_buff *skb = NULL;
|
||||
__le16 *pktlen;
|
||||
struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr;
|
||||
|
||||
if ((skb = dn_alloc_skb(NULL, sizeof(*msg), GFP_ATOMIC)) == NULL)
|
||||
if ((skb = dn_alloc_skb(NULL, sizeof(*msg), GFP_ATOMIC)) == NULL)
|
||||
return;
|
||||
|
||||
skb->dev = dev;
|
||||
skb->dev = dev;
|
||||
|
||||
msg = (struct endnode_hello_message *)skb_put(skb,sizeof(*msg));
|
||||
msg = (struct endnode_hello_message *)skb_put(skb,sizeof(*msg));
|
||||
|
||||
msg->msgflg = 0x0D;
|
||||
memcpy(msg->tiver, dn_eco_version, 3);
|
||||
msg->msgflg = 0x0D;
|
||||
memcpy(msg->tiver, dn_eco_version, 3);
|
||||
dn_dn2eth(msg->id, ifa->ifa_local);
|
||||
msg->iinfo = DN_RT_INFO_ENDN;
|
||||
msg->blksize = dn_htons(mtu2blksize(dev));
|
||||
msg->area = 0x00;
|
||||
memset(msg->seed, 0, 8);
|
||||
memcpy(msg->neighbor, dn_hiord, ETH_ALEN);
|
||||
msg->iinfo = DN_RT_INFO_ENDN;
|
||||
msg->blksize = dn_htons(mtu2blksize(dev));
|
||||
msg->area = 0x00;
|
||||
memset(msg->seed, 0, 8);
|
||||
memcpy(msg->neighbor, dn_hiord, ETH_ALEN);
|
||||
|
||||
if (dn_db->router) {
|
||||
struct dn_neigh *dn = (struct dn_neigh *)dn_db->router;
|
||||
dn_dn2eth(msg->neighbor, dn->addr);
|
||||
}
|
||||
|
||||
msg->timer = dn_htons((unsigned short)dn_db->parms.t3);
|
||||
msg->mpd = 0x00;
|
||||
msg->datalen = 0x02;
|
||||
memset(msg->data, 0xAA, 2);
|
||||
msg->timer = dn_htons((unsigned short)dn_db->parms.t3);
|
||||
msg->mpd = 0x00;
|
||||
msg->datalen = 0x02;
|
||||
memset(msg->data, 0xAA, 2);
|
||||
|
||||
pktlen = (__le16 *)skb_push(skb,2);
|
||||
*pktlen = dn_htons(skb->len - 2);
|
||||
pktlen = (__le16 *)skb_push(skb,2);
|
||||
*pktlen = dn_htons(skb->len - 2);
|
||||
|
||||
skb->nh.raw = skb->data;
|
||||
|
||||
@ -1408,18 +1408,18 @@ static char *dn_type2asc(char type)
|
||||
static int dn_dev_seq_show(struct seq_file *seq, void *v)
|
||||
{
|
||||
if (v == SEQ_START_TOKEN)
|
||||
seq_puts(seq, "Name Flags T1 Timer1 T3 Timer3 BlkSize Pri State DevType Router Peer\n");
|
||||
seq_puts(seq, "Name Flags T1 Timer1 T3 Timer3 BlkSize Pri State DevType Router Peer\n");
|
||||
else {
|
||||
struct net_device *dev = v;
|
||||
char peer_buf[DN_ASCBUF_LEN];
|
||||
char router_buf[DN_ASCBUF_LEN];
|
||||
struct dn_dev *dn_db = dev->dn_ptr;
|
||||
|
||||
seq_printf(seq, "%-8s %1s %04u %04u %04lu %04lu"
|
||||
seq_printf(seq, "%-8s %1s %04u %04u %04lu %04lu"
|
||||
" %04hu %03d %02x %-10s %-7s %-7s\n",
|
||||
dev->name ? dev->name : "???",
|
||||
dn_type2asc(dn_db->parms.mode),
|
||||
0, 0,
|
||||
dev->name ? dev->name : "???",
|
||||
dn_type2asc(dn_db->parms.mode),
|
||||
0, 0,
|
||||
dn_db->t3, dn_db->parms.t3,
|
||||
mtu2blksize(dev),
|
||||
dn_db->parms.priority,
|
||||
@ -1476,17 +1476,17 @@ MODULE_PARM_DESC(addr, "The DECnet address of this machine: area,node");
|
||||
|
||||
void __init dn_dev_init(void)
|
||||
{
|
||||
if (addr[0] > 63 || addr[0] < 0) {
|
||||
printk(KERN_ERR "DECnet: Area must be between 0 and 63");
|
||||
return;
|
||||
}
|
||||
if (addr[0] > 63 || addr[0] < 0) {
|
||||
printk(KERN_ERR "DECnet: Area must be between 0 and 63");
|
||||
return;
|
||||
}
|
||||
|
||||
if (addr[1] > 1023 || addr[1] < 0) {
|
||||
printk(KERN_ERR "DECnet: Node must be between 0 and 1023");
|
||||
return;
|
||||
}
|
||||
if (addr[1] > 1023 || addr[1] < 0) {
|
||||
printk(KERN_ERR "DECnet: Node must be between 0 and 1023");
|
||||
return;
|
||||
}
|
||||
|
||||
decnet_address = dn_htons((addr[0] << 10) | addr[1]);
|
||||
decnet_address = dn_htons((addr[0] << 10) | addr[1]);
|
||||
|
||||
dn_dev_devices_on();
|
||||
|
||||
|
@ -654,80 +654,80 @@ static int dn_fib_dnaddr_event(struct notifier_block *this, unsigned long event,
|
||||
|
||||
static int dn_fib_sync_down(__le16 local, struct net_device *dev, int force)
|
||||
{
|
||||
int ret = 0;
|
||||
int scope = RT_SCOPE_NOWHERE;
|
||||
int ret = 0;
|
||||
int scope = RT_SCOPE_NOWHERE;
|
||||
|
||||
if (force)
|
||||
scope = -1;
|
||||
if (force)
|
||||
scope = -1;
|
||||
|
||||
for_fib_info() {
|
||||
/*
|
||||
* This makes no sense for DECnet.... we will almost
|
||||
* certainly have more than one local address the same
|
||||
* over all our interfaces. It needs thinking about
|
||||
* some more.
|
||||
*/
|
||||
if (local && fi->fib_prefsrc == local) {
|
||||
fi->fib_flags |= RTNH_F_DEAD;
|
||||
ret++;
|
||||
} else if (dev && fi->fib_nhs) {
|
||||
int dead = 0;
|
||||
for_fib_info() {
|
||||
/*
|
||||
* This makes no sense for DECnet.... we will almost
|
||||
* certainly have more than one local address the same
|
||||
* over all our interfaces. It needs thinking about
|
||||
* some more.
|
||||
*/
|
||||
if (local && fi->fib_prefsrc == local) {
|
||||
fi->fib_flags |= RTNH_F_DEAD;
|
||||
ret++;
|
||||
} else if (dev && fi->fib_nhs) {
|
||||
int dead = 0;
|
||||
|
||||
change_nexthops(fi) {
|
||||
if (nh->nh_flags&RTNH_F_DEAD)
|
||||
dead++;
|
||||
else if (nh->nh_dev == dev &&
|
||||
nh->nh_scope != scope) {
|
||||
change_nexthops(fi) {
|
||||
if (nh->nh_flags&RTNH_F_DEAD)
|
||||
dead++;
|
||||
else if (nh->nh_dev == dev &&
|
||||
nh->nh_scope != scope) {
|
||||
spin_lock_bh(&dn_fib_multipath_lock);
|
||||
nh->nh_flags |= RTNH_F_DEAD;
|
||||
fi->fib_power -= nh->nh_power;
|
||||
nh->nh_power = 0;
|
||||
nh->nh_flags |= RTNH_F_DEAD;
|
||||
fi->fib_power -= nh->nh_power;
|
||||
nh->nh_power = 0;
|
||||
spin_unlock_bh(&dn_fib_multipath_lock);
|
||||
dead++;
|
||||
}
|
||||
} endfor_nexthops(fi)
|
||||
if (dead == fi->fib_nhs) {
|
||||
fi->fib_flags |= RTNH_F_DEAD;
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
} endfor_fib_info();
|
||||
return ret;
|
||||
dead++;
|
||||
}
|
||||
} endfor_nexthops(fi)
|
||||
if (dead == fi->fib_nhs) {
|
||||
fi->fib_flags |= RTNH_F_DEAD;
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
} endfor_fib_info();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int dn_fib_sync_up(struct net_device *dev)
|
||||
{
|
||||
int ret = 0;
|
||||
int ret = 0;
|
||||
|
||||
if (!(dev->flags&IFF_UP))
|
||||
return 0;
|
||||
if (!(dev->flags&IFF_UP))
|
||||
return 0;
|
||||
|
||||
for_fib_info() {
|
||||
int alive = 0;
|
||||
for_fib_info() {
|
||||
int alive = 0;
|
||||
|
||||
change_nexthops(fi) {
|
||||
if (!(nh->nh_flags&RTNH_F_DEAD)) {
|
||||
alive++;
|
||||
continue;
|
||||
}
|
||||
if (nh->nh_dev == NULL || !(nh->nh_dev->flags&IFF_UP))
|
||||
continue;
|
||||
if (nh->nh_dev != dev || dev->dn_ptr == NULL)
|
||||
continue;
|
||||
alive++;
|
||||
change_nexthops(fi) {
|
||||
if (!(nh->nh_flags&RTNH_F_DEAD)) {
|
||||
alive++;
|
||||
continue;
|
||||
}
|
||||
if (nh->nh_dev == NULL || !(nh->nh_dev->flags&IFF_UP))
|
||||
continue;
|
||||
if (nh->nh_dev != dev || dev->dn_ptr == NULL)
|
||||
continue;
|
||||
alive++;
|
||||
spin_lock_bh(&dn_fib_multipath_lock);
|
||||
nh->nh_power = 0;
|
||||
nh->nh_flags &= ~RTNH_F_DEAD;
|
||||
nh->nh_power = 0;
|
||||
nh->nh_flags &= ~RTNH_F_DEAD;
|
||||
spin_unlock_bh(&dn_fib_multipath_lock);
|
||||
} endfor_nexthops(fi);
|
||||
} endfor_nexthops(fi);
|
||||
|
||||
if (alive > 0) {
|
||||
fi->fib_flags &= ~RTNH_F_DEAD;
|
||||
ret++;
|
||||
}
|
||||
} endfor_fib_info();
|
||||
return ret;
|
||||
if (alive > 0) {
|
||||
fi->fib_flags &= ~RTNH_F_DEAD;
|
||||
ret++;
|
||||
}
|
||||
} endfor_fib_info();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct notifier_block dn_fib_dnaddr_notifier = {
|
||||
|
@ -277,19 +277,19 @@ static int dn_short_output(struct sk_buff *skb)
|
||||
struct dn_skb_cb *cb = DN_SKB_CB(skb);
|
||||
|
||||
|
||||
if (skb_headroom(skb) < headroom) {
|
||||
struct sk_buff *skb2 = skb_realloc_headroom(skb, headroom);
|
||||
if (skb2 == NULL) {
|
||||
if (skb_headroom(skb) < headroom) {
|
||||
struct sk_buff *skb2 = skb_realloc_headroom(skb, headroom);
|
||||
if (skb2 == NULL) {
|
||||
if (net_ratelimit())
|
||||
printk(KERN_CRIT "dn_short_output: no memory\n");
|
||||
kfree_skb(skb);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
kfree_skb(skb);
|
||||
skb = skb2;
|
||||
printk(KERN_CRIT "dn_short_output: no memory\n");
|
||||
kfree_skb(skb);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
kfree_skb(skb);
|
||||
skb = skb2;
|
||||
if (net_ratelimit())
|
||||
printk(KERN_INFO "dn_short_output: Increasing headroom\n");
|
||||
}
|
||||
printk(KERN_INFO "dn_short_output: Increasing headroom\n");
|
||||
}
|
||||
|
||||
data = skb_push(skb, sizeof(struct dn_short_packet) + 2);
|
||||
*((__le16 *)data) = dn_htons(skb->len - 2);
|
||||
|
@ -349,9 +349,9 @@ static void dn_nsp_conn_conf(struct sock *sk, struct sk_buff *skb)
|
||||
|
||||
if ((scp->state == DN_CI) || (scp->state == DN_CD)) {
|
||||
scp->persist = 0;
|
||||
scp->addrrem = cb->src_port;
|
||||
sk->sk_state = TCP_ESTABLISHED;
|
||||
scp->state = DN_RUN;
|
||||
scp->addrrem = cb->src_port;
|
||||
sk->sk_state = TCP_ESTABLISHED;
|
||||
scp->state = DN_RUN;
|
||||
scp->services_rem = cb->services;
|
||||
scp->info_rem = cb->info;
|
||||
scp->segsize_rem = cb->segsize;
|
||||
@ -366,13 +366,13 @@ static void dn_nsp_conn_conf(struct sock *sk, struct sk_buff *skb)
|
||||
memcpy(scp->conndata_in.opt_data, skb->data + 1, dlen);
|
||||
}
|
||||
}
|
||||
dn_nsp_send_link(sk, DN_NOCHANGE, 0);
|
||||
if (!sock_flag(sk, SOCK_DEAD))
|
||||
sk->sk_state_change(sk);
|
||||
}
|
||||
dn_nsp_send_link(sk, DN_NOCHANGE, 0);
|
||||
if (!sock_flag(sk, SOCK_DEAD))
|
||||
sk->sk_state_change(sk);
|
||||
}
|
||||
|
||||
out:
|
||||
kfree_skb(skb);
|
||||
kfree_skb(skb);
|
||||
}
|
||||
|
||||
static void dn_nsp_conn_ack(struct sock *sk, struct sk_buff *skb)
|
||||
@ -530,7 +530,7 @@ static void dn_nsp_linkservice(struct sock *sk, struct sk_buff *skb)
|
||||
switch(lsflags & 0x04) { /* FCVAL INT */
|
||||
case 0x00: /* Normal Request */
|
||||
switch(lsflags & 0x03) { /* FCVAL MOD */
|
||||
case 0x00: /* Request count */
|
||||
case 0x00: /* Request count */
|
||||
if (fcval < 0) {
|
||||
unsigned char p_fcval = -fcval;
|
||||
if ((scp->flowrem_dat > p_fcval) &&
|
||||
@ -541,7 +541,7 @@ static void dn_nsp_linkservice(struct sock *sk, struct sk_buff *skb)
|
||||
scp->flowrem_dat += fcval;
|
||||
wake_up = 1;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0x01: /* Stop outgoing data */
|
||||
scp->flowrem_sw = DN_DONTSEND;
|
||||
break;
|
||||
@ -557,10 +557,10 @@ static void dn_nsp_linkservice(struct sock *sk, struct sk_buff *skb)
|
||||
wake_up = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (wake_up && !sock_flag(sk, SOCK_DEAD))
|
||||
sk->sk_state_change(sk);
|
||||
}
|
||||
}
|
||||
|
||||
dn_nsp_send_oth_ack(sk);
|
||||
|
||||
@ -577,27 +577,27 @@ static __inline__ int dn_queue_skb(struct sock *sk, struct sk_buff *skb, int sig
|
||||
{
|
||||
int err;
|
||||
|
||||
/* Cast skb->rcvbuf to unsigned... It's pointless, but reduces
|
||||
number of warnings when compiling with -W --ANK
|
||||
*/
|
||||
if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
|
||||
/* Cast skb->rcvbuf to unsigned... It's pointless, but reduces
|
||||
number of warnings when compiling with -W --ANK
|
||||
*/
|
||||
if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
|
||||
(unsigned)sk->sk_rcvbuf) {
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
err = sk_filter(sk, skb);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
skb_set_owner_r(skb, sk);
|
||||
skb_queue_tail(queue, skb);
|
||||
skb_set_owner_r(skb, sk);
|
||||
skb_queue_tail(queue, skb);
|
||||
|
||||
/* This code only runs from BH or BH protected context.
|
||||
* Therefore the plain read_lock is ok here. -DaveM
|
||||
*/
|
||||
read_lock(&sk->sk_callback_lock);
|
||||
if (!sock_flag(sk, SOCK_DEAD)) {
|
||||
if (!sock_flag(sk, SOCK_DEAD)) {
|
||||
struct socket *sock = sk->sk_socket;
|
||||
wake_up_interruptible(sk->sk_sleep);
|
||||
if (sock && sock->fasync_list &&
|
||||
@ -607,7 +607,7 @@ static __inline__ int dn_queue_skb(struct sock *sk, struct sk_buff *skb, int sig
|
||||
}
|
||||
read_unlock(&sk->sk_callback_lock);
|
||||
out:
|
||||
return err;
|
||||
return err;
|
||||
}
|
||||
|
||||
static void dn_nsp_otherdata(struct sock *sk, struct sk_buff *skb)
|
||||
@ -652,16 +652,16 @@ static void dn_nsp_data(struct sock *sk, struct sk_buff *skb)
|
||||
skb_pull(skb, 2);
|
||||
|
||||
if (seq_next(scp->numdat_rcv, segnum)) {
|
||||
if (dn_queue_skb(sk, skb, SIGIO, &sk->sk_receive_queue) == 0) {
|
||||
if (dn_queue_skb(sk, skb, SIGIO, &sk->sk_receive_queue) == 0) {
|
||||
seq_add(&scp->numdat_rcv, 1);
|
||||
queued = 1;
|
||||
}
|
||||
queued = 1;
|
||||
}
|
||||
|
||||
if ((scp->flowloc_sw == DN_SEND) && dn_congested(sk)) {
|
||||
scp->flowloc_sw = DN_DONTSEND;
|
||||
dn_nsp_send_link(sk, DN_DONTSEND, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dn_nsp_send_data_ack(sk);
|
||||
out:
|
||||
|
@ -486,13 +486,13 @@ void dn_send_conn_ack (struct sock *sk)
|
||||
{
|
||||
struct dn_scp *scp = DN_SK(sk);
|
||||
struct sk_buff *skb = NULL;
|
||||
struct nsp_conn_ack_msg *msg;
|
||||
struct nsp_conn_ack_msg *msg;
|
||||
|
||||
if ((skb = dn_alloc_skb(sk, 3, sk->sk_allocation)) == NULL)
|
||||
return;
|
||||
|
||||
msg = (struct nsp_conn_ack_msg *)skb_put(skb, 3);
|
||||
msg->msgflg = 0x24;
|
||||
msg = (struct nsp_conn_ack_msg *)skb_put(skb, 3);
|
||||
msg->msgflg = 0x24;
|
||||
msg->dstaddr = scp->addrrem;
|
||||
|
||||
dn_nsp_send(skb);
|
||||
@ -523,19 +523,19 @@ void dn_send_conn_conf(struct sock *sk, gfp_t gfp)
|
||||
{
|
||||
struct dn_scp *scp = DN_SK(sk);
|
||||
struct sk_buff *skb = NULL;
|
||||
struct nsp_conn_init_msg *msg;
|
||||
struct nsp_conn_init_msg *msg;
|
||||
__u8 len = (__u8)dn_ntohs(scp->conndata_out.opt_optl);
|
||||
|
||||
if ((skb = dn_alloc_skb(sk, 50 + len, gfp)) == NULL)
|
||||
return;
|
||||
|
||||
msg = (struct nsp_conn_init_msg *)skb_put(skb, sizeof(*msg));
|
||||
msg->msgflg = 0x28;
|
||||
msg = (struct nsp_conn_init_msg *)skb_put(skb, sizeof(*msg));
|
||||
msg->msgflg = 0x28;
|
||||
msg->dstaddr = scp->addrrem;
|
||||
msg->srcaddr = scp->addrloc;
|
||||
msg->services = scp->services_loc;
|
||||
msg->info = scp->info_loc;
|
||||
msg->segsize = dn_htons(scp->segsize_loc);
|
||||
msg->srcaddr = scp->addrloc;
|
||||
msg->services = scp->services_loc;
|
||||
msg->info = scp->info_loc;
|
||||
msg->segsize = dn_htons(scp->segsize_loc);
|
||||
|
||||
*skb_put(skb,1) = len;
|
||||
|
||||
|
@ -506,23 +506,23 @@ static int dn_route_rx_long(struct sk_buff *skb)
|
||||
skb_pull(skb, 20);
|
||||
skb->h.raw = skb->data;
|
||||
|
||||
/* Destination info */
|
||||
ptr += 2;
|
||||
/* Destination info */
|
||||
ptr += 2;
|
||||
cb->dst = dn_eth2dn(ptr);
|
||||
if (memcmp(ptr, dn_hiord_addr, 4) != 0)
|
||||
goto drop_it;
|
||||
ptr += 6;
|
||||
if (memcmp(ptr, dn_hiord_addr, 4) != 0)
|
||||
goto drop_it;
|
||||
ptr += 6;
|
||||
|
||||
|
||||
/* Source info */
|
||||
ptr += 2;
|
||||
/* Source info */
|
||||
ptr += 2;
|
||||
cb->src = dn_eth2dn(ptr);
|
||||
if (memcmp(ptr, dn_hiord_addr, 4) != 0)
|
||||
goto drop_it;
|
||||
ptr += 6;
|
||||
/* Other junk */
|
||||
ptr++;
|
||||
cb->hops = *ptr++; /* Visit Count */
|
||||
if (memcmp(ptr, dn_hiord_addr, 4) != 0)
|
||||
goto drop_it;
|
||||
ptr += 6;
|
||||
/* Other junk */
|
||||
ptr++;
|
||||
cb->hops = *ptr++; /* Visit Count */
|
||||
|
||||
return NF_HOOK(PF_DECnet, NF_DN_PRE_ROUTING, skb, skb->dev, NULL, dn_route_rx_packet);
|
||||
|
||||
@ -545,16 +545,16 @@ static int dn_route_rx_short(struct sk_buff *skb)
|
||||
skb->h.raw = skb->data;
|
||||
|
||||
cb->dst = *(__le16 *)ptr;
|
||||
ptr += 2;
|
||||
cb->src = *(__le16 *)ptr;
|
||||
ptr += 2;
|
||||
cb->hops = *ptr & 0x3f;
|
||||
ptr += 2;
|
||||
cb->src = *(__le16 *)ptr;
|
||||
ptr += 2;
|
||||
cb->hops = *ptr & 0x3f;
|
||||
|
||||
return NF_HOOK(PF_DECnet, NF_DN_PRE_ROUTING, skb, skb->dev, NULL, dn_route_rx_packet);
|
||||
|
||||
drop_it:
|
||||
kfree_skb(skb);
|
||||
return NET_RX_DROP;
|
||||
kfree_skb(skb);
|
||||
return NET_RX_DROP;
|
||||
}
|
||||
|
||||
static int dn_route_discard(struct sk_buff *skb)
|
||||
@ -631,15 +631,15 @@ int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type
|
||||
(int)flags, (dev) ? dev->name : "???", len, skb->len,
|
||||
padlen);
|
||||
|
||||
if (flags & DN_RT_PKT_CNTL) {
|
||||
if (flags & DN_RT_PKT_CNTL) {
|
||||
if (unlikely(skb_linearize(skb)))
|
||||
goto dump_it;
|
||||
|
||||
switch(flags & DN_RT_CNTL_MSK) {
|
||||
case DN_RT_PKT_INIT:
|
||||
switch(flags & DN_RT_CNTL_MSK) {
|
||||
case DN_RT_PKT_INIT:
|
||||
dn_dev_init_pkt(skb);
|
||||
break;
|
||||
case DN_RT_PKT_VERI:
|
||||
case DN_RT_PKT_VERI:
|
||||
dn_dev_veri_pkt(skb);
|
||||
break;
|
||||
}
|
||||
@ -648,31 +648,31 @@ int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type
|
||||
goto dump_it;
|
||||
|
||||
switch(flags & DN_RT_CNTL_MSK) {
|
||||
case DN_RT_PKT_HELO:
|
||||
case DN_RT_PKT_HELO:
|
||||
return NF_HOOK(PF_DECnet, NF_DN_HELLO, skb, skb->dev, NULL, dn_route_ptp_hello);
|
||||
|
||||
case DN_RT_PKT_L1RT:
|
||||
case DN_RT_PKT_L2RT:
|
||||
return NF_HOOK(PF_DECnet, NF_DN_ROUTE, skb, skb->dev, NULL, dn_route_discard);
|
||||
case DN_RT_PKT_ERTH:
|
||||
case DN_RT_PKT_L1RT:
|
||||
case DN_RT_PKT_L2RT:
|
||||
return NF_HOOK(PF_DECnet, NF_DN_ROUTE, skb, skb->dev, NULL, dn_route_discard);
|
||||
case DN_RT_PKT_ERTH:
|
||||
return NF_HOOK(PF_DECnet, NF_DN_HELLO, skb, skb->dev, NULL, dn_neigh_router_hello);
|
||||
|
||||
case DN_RT_PKT_EEDH:
|
||||
case DN_RT_PKT_EEDH:
|
||||
return NF_HOOK(PF_DECnet, NF_DN_HELLO, skb, skb->dev, NULL, dn_neigh_endnode_hello);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
if (dn->parms.state != DN_DEV_S_RU)
|
||||
goto dump_it;
|
||||
|
||||
skb_pull(skb, 1); /* Pull flags */
|
||||
|
||||
switch(flags & DN_RT_PKT_MSK) {
|
||||
case DN_RT_PKT_LONG:
|
||||
return dn_route_rx_long(skb);
|
||||
case DN_RT_PKT_SHORT:
|
||||
return dn_route_rx_short(skb);
|
||||
switch(flags & DN_RT_PKT_MSK) {
|
||||
case DN_RT_PKT_LONG:
|
||||
return dn_route_rx_long(skb);
|
||||
case DN_RT_PKT_SHORT:
|
||||
return dn_route_rx_short(skb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dump_it:
|
||||
kfree_skb(skb);
|
||||
@ -816,7 +816,7 @@ static int dn_rt_set_next_hop(struct dn_route *rt, struct dn_fib_res *res)
|
||||
}
|
||||
|
||||
if (rt->u.dst.metrics[RTAX_MTU-1] == 0 ||
|
||||
rt->u.dst.metrics[RTAX_MTU-1] > rt->u.dst.dev->mtu)
|
||||
rt->u.dst.metrics[RTAX_MTU-1] > rt->u.dst.dev->mtu)
|
||||
rt->u.dst.metrics[RTAX_MTU-1] = rt->u.dst.dev->mtu;
|
||||
mss = dn_mss_from_pmtu(dev, dst_mtu(&rt->u.dst));
|
||||
if (rt->u.dst.metrics[RTAX_ADVMSS-1] == 0 ||
|
||||
@ -899,7 +899,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
|
||||
"dn_route_output_slow: dst=%04x src=%04x mark=%d"
|
||||
" iif=%d oif=%d\n", dn_ntohs(oldflp->fld_dst),
|
||||
dn_ntohs(oldflp->fld_src),
|
||||
oldflp->mark, loopback_dev.ifindex, oldflp->oif);
|
||||
oldflp->mark, loopback_dev.ifindex, oldflp->oif);
|
||||
|
||||
/* If we have an output interface, verify its a DECnet device */
|
||||
if (oldflp->oif) {
|
||||
@ -982,7 +982,7 @@ source_ok:
|
||||
if (err != -ESRCH)
|
||||
goto out;
|
||||
/*
|
||||
* Here the fallback is basically the standard algorithm for
|
||||
* Here the fallback is basically the standard algorithm for
|
||||
* routing in endnodes which is described in the DECnet routing
|
||||
* docs
|
||||
*
|
||||
@ -1144,8 +1144,8 @@ out:
|
||||
return err;
|
||||
|
||||
e_addr:
|
||||
err = -EADDRNOTAVAIL;
|
||||
goto done;
|
||||
err = -EADDRNOTAVAIL;
|
||||
goto done;
|
||||
e_inval:
|
||||
err = -EINVAL;
|
||||
goto done;
|
||||
@ -1445,7 +1445,7 @@ int dn_route_input(struct sk_buff *skb)
|
||||
for(rt = rcu_dereference(dn_rt_hash_table[hash].chain); rt != NULL;
|
||||
rt = rcu_dereference(rt->u.rt_next)) {
|
||||
if ((rt->fl.fld_src == cb->src) &&
|
||||
(rt->fl.fld_dst == cb->dst) &&
|
||||
(rt->fl.fld_dst == cb->dst) &&
|
||||
(rt->fl.oif == 0) &&
|
||||
(rt->fl.mark == skb->mark) &&
|
||||
(rt->fl.iif == cb->iif)) {
|
||||
@ -1514,8 +1514,8 @@ static int dn_rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
|
||||
|
||||
nlmsg_failure:
|
||||
rtattr_failure:
|
||||
skb_trim(skb, b - skb->data);
|
||||
return -1;
|
||||
skb_trim(skb, b - skb->data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1778,25 +1778,25 @@ void __init dn_route_init(void)
|
||||
for(order = 0; (1UL << order) < goal; order++)
|
||||
/* NOTHING */;
|
||||
|
||||
/*
|
||||
* Only want 1024 entries max, since the table is very, very unlikely
|
||||
* to be larger than that.
|
||||
*/
|
||||
while(order && ((((1UL << order) * PAGE_SIZE) /
|
||||
sizeof(struct dn_rt_hash_bucket)) >= 2048))
|
||||
order--;
|
||||
/*
|
||||
* Only want 1024 entries max, since the table is very, very unlikely
|
||||
* to be larger than that.
|
||||
*/
|
||||
while(order && ((((1UL << order) * PAGE_SIZE) /
|
||||
sizeof(struct dn_rt_hash_bucket)) >= 2048))
|
||||
order--;
|
||||
|
||||
do {
|
||||
dn_rt_hash_mask = (1UL << order) * PAGE_SIZE /
|
||||
sizeof(struct dn_rt_hash_bucket);
|
||||
while(dn_rt_hash_mask & (dn_rt_hash_mask - 1))
|
||||
dn_rt_hash_mask--;
|
||||
dn_rt_hash_table = (struct dn_rt_hash_bucket *)
|
||||
__get_free_pages(GFP_ATOMIC, order);
|
||||
} while (dn_rt_hash_table == NULL && --order > 0);
|
||||
do {
|
||||
dn_rt_hash_mask = (1UL << order) * PAGE_SIZE /
|
||||
sizeof(struct dn_rt_hash_bucket);
|
||||
while(dn_rt_hash_mask & (dn_rt_hash_mask - 1))
|
||||
dn_rt_hash_mask--;
|
||||
dn_rt_hash_table = (struct dn_rt_hash_bucket *)
|
||||
__get_free_pages(GFP_ATOMIC, order);
|
||||
} while (dn_rt_hash_table == NULL && --order > 0);
|
||||
|
||||
if (!dn_rt_hash_table)
|
||||
panic("Failed to allocate DECnet route cache hash table\n");
|
||||
panic("Failed to allocate DECnet route cache hash table\n");
|
||||
|
||||
printk(KERN_INFO
|
||||
"DECnet: Routing cache hash table of %u buckets, %ldKbytes\n",
|
||||
@ -1804,12 +1804,12 @@ void __init dn_route_init(void)
|
||||
(long)(dn_rt_hash_mask*sizeof(struct dn_rt_hash_bucket))/1024);
|
||||
|
||||
dn_rt_hash_mask--;
|
||||
for(i = 0; i <= dn_rt_hash_mask; i++) {
|
||||
spin_lock_init(&dn_rt_hash_table[i].lock);
|
||||
dn_rt_hash_table[i].chain = NULL;
|
||||
}
|
||||
for(i = 0; i <= dn_rt_hash_mask; i++) {
|
||||
spin_lock_init(&dn_rt_hash_table[i].lock);
|
||||
dn_rt_hash_table[i].chain = NULL;
|
||||
}
|
||||
|
||||
dn_dst_ops.gc_thresh = (dn_rt_hash_mask + 1);
|
||||
dn_dst_ops.gc_thresh = (dn_rt_hash_mask + 1);
|
||||
|
||||
proc_net_fops_create("decnet_cache", S_IRUGO, &dn_rt_cache_seq_fops);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ struct dn_hash
|
||||
#define dz_prefix(key,dz) ((key).datum)
|
||||
|
||||
#define for_nexthops(fi) { int nhsel; const struct dn_fib_nh *nh;\
|
||||
for(nhsel = 0, nh = (fi)->fib_nh; nhsel < (fi)->fib_nhs; nh++, nhsel++)
|
||||
for(nhsel = 0, nh = (fi)->fib_nh; nhsel < (fi)->fib_nhs; nh++, nhsel++)
|
||||
|
||||
#define endfor_nexthops(fi) }
|
||||
|
||||
@ -290,82 +290,82 @@ static inline size_t dn_fib_nlmsg_size(struct dn_fib_info *fi)
|
||||
}
|
||||
|
||||
static int dn_fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
|
||||
u32 tb_id, u8 type, u8 scope, void *dst, int dst_len,
|
||||
struct dn_fib_info *fi, unsigned int flags)
|
||||
u32 tb_id, u8 type, u8 scope, void *dst, int dst_len,
|
||||
struct dn_fib_info *fi, unsigned int flags)
|
||||
{
|
||||
struct rtmsg *rtm;
|
||||
struct nlmsghdr *nlh;
|
||||
unsigned char *b = skb->tail;
|
||||
struct rtmsg *rtm;
|
||||
struct nlmsghdr *nlh;
|
||||
unsigned char *b = skb->tail;
|
||||
|
||||
nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*rtm), flags);
|
||||
rtm = NLMSG_DATA(nlh);
|
||||
rtm->rtm_family = AF_DECnet;
|
||||
rtm->rtm_dst_len = dst_len;
|
||||
rtm->rtm_src_len = 0;
|
||||
rtm->rtm_tos = 0;
|
||||
rtm->rtm_table = tb_id;
|
||||
nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*rtm), flags);
|
||||
rtm = NLMSG_DATA(nlh);
|
||||
rtm->rtm_family = AF_DECnet;
|
||||
rtm->rtm_dst_len = dst_len;
|
||||
rtm->rtm_src_len = 0;
|
||||
rtm->rtm_tos = 0;
|
||||
rtm->rtm_table = tb_id;
|
||||
RTA_PUT_U32(skb, RTA_TABLE, tb_id);
|
||||
rtm->rtm_flags = fi->fib_flags;
|
||||
rtm->rtm_scope = scope;
|
||||
rtm->rtm_flags = fi->fib_flags;
|
||||
rtm->rtm_scope = scope;
|
||||
rtm->rtm_type = type;
|
||||
if (rtm->rtm_dst_len)
|
||||
RTA_PUT(skb, RTA_DST, 2, dst);
|
||||
rtm->rtm_protocol = fi->fib_protocol;
|
||||
if (fi->fib_priority)
|
||||
RTA_PUT(skb, RTA_PRIORITY, 4, &fi->fib_priority);
|
||||
if (rtm->rtm_dst_len)
|
||||
RTA_PUT(skb, RTA_DST, 2, dst);
|
||||
rtm->rtm_protocol = fi->fib_protocol;
|
||||
if (fi->fib_priority)
|
||||
RTA_PUT(skb, RTA_PRIORITY, 4, &fi->fib_priority);
|
||||
if (rtnetlink_put_metrics(skb, fi->fib_metrics) < 0)
|
||||
goto rtattr_failure;
|
||||
if (fi->fib_nhs == 1) {
|
||||
if (fi->fib_nh->nh_gw)
|
||||
RTA_PUT(skb, RTA_GATEWAY, 2, &fi->fib_nh->nh_gw);
|
||||
if (fi->fib_nh->nh_oif)
|
||||
RTA_PUT(skb, RTA_OIF, sizeof(int), &fi->fib_nh->nh_oif);
|
||||
}
|
||||
if (fi->fib_nhs > 1) {
|
||||
struct rtnexthop *nhp;
|
||||
struct rtattr *mp_head;
|
||||
if (skb_tailroom(skb) <= RTA_SPACE(0))
|
||||
goto rtattr_failure;
|
||||
mp_head = (struct rtattr *)skb_put(skb, RTA_SPACE(0));
|
||||
if (fi->fib_nhs == 1) {
|
||||
if (fi->fib_nh->nh_gw)
|
||||
RTA_PUT(skb, RTA_GATEWAY, 2, &fi->fib_nh->nh_gw);
|
||||
if (fi->fib_nh->nh_oif)
|
||||
RTA_PUT(skb, RTA_OIF, sizeof(int), &fi->fib_nh->nh_oif);
|
||||
}
|
||||
if (fi->fib_nhs > 1) {
|
||||
struct rtnexthop *nhp;
|
||||
struct rtattr *mp_head;
|
||||
if (skb_tailroom(skb) <= RTA_SPACE(0))
|
||||
goto rtattr_failure;
|
||||
mp_head = (struct rtattr *)skb_put(skb, RTA_SPACE(0));
|
||||
|
||||
for_nexthops(fi) {
|
||||
if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4))
|
||||
goto rtattr_failure;
|
||||
nhp = (struct rtnexthop *)skb_put(skb, RTA_ALIGN(sizeof(*nhp)));
|
||||
nhp->rtnh_flags = nh->nh_flags & 0xFF;
|
||||
nhp->rtnh_hops = nh->nh_weight - 1;
|
||||
nhp->rtnh_ifindex = nh->nh_oif;
|
||||
if (nh->nh_gw)
|
||||
RTA_PUT(skb, RTA_GATEWAY, 2, &nh->nh_gw);
|
||||
nhp->rtnh_len = skb->tail - (unsigned char *)nhp;
|
||||
} endfor_nexthops(fi);
|
||||
mp_head->rta_type = RTA_MULTIPATH;
|
||||
mp_head->rta_len = skb->tail - (u8*)mp_head;
|
||||
}
|
||||
for_nexthops(fi) {
|
||||
if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4))
|
||||
goto rtattr_failure;
|
||||
nhp = (struct rtnexthop *)skb_put(skb, RTA_ALIGN(sizeof(*nhp)));
|
||||
nhp->rtnh_flags = nh->nh_flags & 0xFF;
|
||||
nhp->rtnh_hops = nh->nh_weight - 1;
|
||||
nhp->rtnh_ifindex = nh->nh_oif;
|
||||
if (nh->nh_gw)
|
||||
RTA_PUT(skb, RTA_GATEWAY, 2, &nh->nh_gw);
|
||||
nhp->rtnh_len = skb->tail - (unsigned char *)nhp;
|
||||
} endfor_nexthops(fi);
|
||||
mp_head->rta_type = RTA_MULTIPATH;
|
||||
mp_head->rta_len = skb->tail - (u8*)mp_head;
|
||||
}
|
||||
|
||||
nlh->nlmsg_len = skb->tail - b;
|
||||
return skb->len;
|
||||
nlh->nlmsg_len = skb->tail - b;
|
||||
return skb->len;
|
||||
|
||||
|
||||
nlmsg_failure:
|
||||
rtattr_failure:
|
||||
skb_trim(skb, b - skb->data);
|
||||
return -EMSGSIZE;
|
||||
skb_trim(skb, b - skb->data);
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
|
||||
static void dn_rtmsg_fib(int event, struct dn_fib_node *f, int z, u32 tb_id,
|
||||
struct nlmsghdr *nlh, struct netlink_skb_parms *req)
|
||||
struct nlmsghdr *nlh, struct netlink_skb_parms *req)
|
||||
{
|
||||
struct sk_buff *skb;
|
||||
u32 pid = req ? req->pid : 0;
|
||||
struct sk_buff *skb;
|
||||
u32 pid = req ? req->pid : 0;
|
||||
int err = -ENOBUFS;
|
||||
|
||||
skb = nlmsg_new(dn_fib_nlmsg_size(DN_FIB_INFO(f)), GFP_KERNEL);
|
||||
if (skb == NULL)
|
||||
skb = nlmsg_new(dn_fib_nlmsg_size(DN_FIB_INFO(f)), GFP_KERNEL);
|
||||
if (skb == NULL)
|
||||
goto errout;
|
||||
|
||||
err = dn_fib_dump_info(skb, pid, nlh->nlmsg_seq, event, tb_id,
|
||||
err = dn_fib_dump_info(skb, pid, nlh->nlmsg_seq, event, tb_id,
|
||||
f->fn_type, f->fn_scope, &f->fn_key, z,
|
||||
DN_FIB_INFO(f), 0);
|
||||
if (err < 0) {
|
||||
@ -434,9 +434,9 @@ static __inline__ int dn_hash_dump_zone(struct sk_buff *skb,
|
||||
}
|
||||
|
||||
static int dn_fib_table_dump(struct dn_fib_table *tb, struct sk_buff *skb,
|
||||
struct netlink_callback *cb)
|
||||
struct netlink_callback *cb)
|
||||
{
|
||||
int m, s_m;
|
||||
int m, s_m;
|
||||
struct dn_zone *dz;
|
||||
struct dn_hash *table = (struct dn_hash *)tb->data;
|
||||
|
||||
@ -457,7 +457,7 @@ static int dn_fib_table_dump(struct dn_fib_table *tb, struct sk_buff *skb,
|
||||
read_unlock(&dn_fib_tables_lock);
|
||||
cb->args[2] = m;
|
||||
|
||||
return skb->len;
|
||||
return skb->len;
|
||||
}
|
||||
|
||||
int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
@ -482,7 +482,7 @@ int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
goto next;
|
||||
if (dumped)
|
||||
memset(&cb->args[2], 0, sizeof(cb->args) -
|
||||
2 * sizeof(cb->args[0]));
|
||||
2 * sizeof(cb->args[0]));
|
||||
if (tb->dump(tb, skb, cb) < 0)
|
||||
goto out;
|
||||
dumped = 1;
|
||||
@ -503,13 +503,13 @@ static int dn_fib_table_insert(struct dn_fib_table *tb, struct rtmsg *r, struct
|
||||
struct dn_fib_node *new_f, *f, **fp, **del_fp;
|
||||
struct dn_zone *dz;
|
||||
struct dn_fib_info *fi;
|
||||
int z = r->rtm_dst_len;
|
||||
int z = r->rtm_dst_len;
|
||||
int type = r->rtm_type;
|
||||
dn_fib_key_t key;
|
||||
int err;
|
||||
int err;
|
||||
|
||||
if (z > 16)
|
||||
return -EINVAL;
|
||||
if (z > 16)
|
||||
return -EINVAL;
|
||||
|
||||
dz = table->dh_zones[z];
|
||||
if (!dz && !(dz = dn_new_zone(table, z)))
|
||||
@ -524,8 +524,8 @@ static int dn_fib_table_insert(struct dn_fib_table *tb, struct rtmsg *r, struct
|
||||
key = dz_key(dst, dz);
|
||||
}
|
||||
|
||||
if ((fi = dn_fib_create_info(r, rta, n, &err)) == NULL)
|
||||
return err;
|
||||
if ((fi = dn_fib_create_info(r, rta, n, &err)) == NULL)
|
||||
return err;
|
||||
|
||||
if (dz->dz_nent > (dz->dz_divisor << 2) &&
|
||||
dz->dz_divisor > DN_MAX_DIVISOR &&
|
||||
@ -626,9 +626,9 @@ replace:
|
||||
dn_rt_cache_flush(-1);
|
||||
}
|
||||
|
||||
dn_rtmsg_fib(RTM_NEWROUTE, new_f, z, tb->n, n, req);
|
||||
dn_rtmsg_fib(RTM_NEWROUTE, new_f, z, tb->n, n, req);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
out:
|
||||
dn_fib_release_info(fi);
|
||||
return err;
|
||||
@ -639,14 +639,14 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct
|
||||
{
|
||||
struct dn_hash *table = (struct dn_hash*)tb->data;
|
||||
struct dn_fib_node **fp, **del_fp, *f;
|
||||
int z = r->rtm_dst_len;
|
||||
int z = r->rtm_dst_len;
|
||||
struct dn_zone *dz;
|
||||
dn_fib_key_t key;
|
||||
int matched;
|
||||
|
||||
|
||||
if (z > 16)
|
||||
return -EINVAL;
|
||||
if (z > 16)
|
||||
return -EINVAL;
|
||||
|
||||
if ((dz = table->dh_zones[z]) == NULL)
|
||||
return -ESRCH;
|
||||
@ -690,7 +690,7 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct
|
||||
|
||||
if (del_fp) {
|
||||
f = *del_fp;
|
||||
dn_rtmsg_fib(RTM_DELROUTE, f, z, tb->n, n, req);
|
||||
dn_rtmsg_fib(RTM_DELROUTE, f, z, tb->n, n, req);
|
||||
|
||||
if (matched != 1) {
|
||||
write_lock_bh(&dn_fib_tables_lock);
|
||||
@ -714,7 +714,7 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -ESRCH;
|
||||
return -ESRCH;
|
||||
}
|
||||
|
||||
static inline int dn_flush_list(struct dn_fib_node **fp, int z, struct dn_hash *table)
|
||||
@ -761,7 +761,7 @@ static int dn_fib_table_flush(struct dn_fib_table *tb)
|
||||
|
||||
static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp, struct dn_fib_res *res)
|
||||
{
|
||||
int err;
|
||||
int err;
|
||||
struct dn_zone *dz;
|
||||
struct dn_hash *t = (struct dn_hash *)tb->data;
|
||||
|
||||
@ -801,21 +801,21 @@ static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp,
|
||||
err = 1;
|
||||
out:
|
||||
read_unlock(&dn_fib_tables_lock);
|
||||
return err;
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
struct dn_fib_table *dn_fib_get_table(u32 n, int create)
|
||||
{
|
||||
struct dn_fib_table *t;
|
||||
struct dn_fib_table *t;
|
||||
struct hlist_node *node;
|
||||
unsigned int h;
|
||||
|
||||
if (n < RT_TABLE_MIN)
|
||||
return NULL;
|
||||
if (n < RT_TABLE_MIN)
|
||||
return NULL;
|
||||
|
||||
if (n > RT_TABLE_MAX)
|
||||
return NULL;
|
||||
if (n > RT_TABLE_MAX)
|
||||
return NULL;
|
||||
|
||||
h = n & (DN_FIB_TABLE_HASHSZ - 1);
|
||||
rcu_read_lock();
|
||||
@ -827,54 +827,54 @@ struct dn_fib_table *dn_fib_get_table(u32 n, int create)
|
||||
}
|
||||
rcu_read_unlock();
|
||||
|
||||
if (!create)
|
||||
return NULL;
|
||||
if (!create)
|
||||
return NULL;
|
||||
|
||||
if (in_interrupt() && net_ratelimit()) {
|
||||
printk(KERN_DEBUG "DECnet: BUG! Attempt to create routing table from interrupt\n");
|
||||
return NULL;
|
||||
}
|
||||
if (in_interrupt() && net_ratelimit()) {
|
||||
printk(KERN_DEBUG "DECnet: BUG! Attempt to create routing table from interrupt\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
t = kzalloc(sizeof(struct dn_fib_table) + sizeof(struct dn_hash),
|
||||
t = kzalloc(sizeof(struct dn_fib_table) + sizeof(struct dn_hash),
|
||||
GFP_KERNEL);
|
||||
if (t == NULL)
|
||||
return NULL;
|
||||
if (t == NULL)
|
||||
return NULL;
|
||||
|
||||
t->n = n;
|
||||
t->insert = dn_fib_table_insert;
|
||||
t->delete = dn_fib_table_delete;
|
||||
t->lookup = dn_fib_table_lookup;
|
||||
t->flush = dn_fib_table_flush;
|
||||
t->dump = dn_fib_table_dump;
|
||||
t->n = n;
|
||||
t->insert = dn_fib_table_insert;
|
||||
t->delete = dn_fib_table_delete;
|
||||
t->lookup = dn_fib_table_lookup;
|
||||
t->flush = dn_fib_table_flush;
|
||||
t->dump = dn_fib_table_dump;
|
||||
hlist_add_head_rcu(&t->hlist, &dn_fib_table_hash[h]);
|
||||
|
||||
return t;
|
||||
return t;
|
||||
}
|
||||
|
||||
struct dn_fib_table *dn_fib_empty_table(void)
|
||||
{
|
||||
u32 id;
|
||||
u32 id;
|
||||
|
||||
for(id = RT_TABLE_MIN; id <= RT_TABLE_MAX; id++)
|
||||
for(id = RT_TABLE_MIN; id <= RT_TABLE_MAX; id++)
|
||||
if (dn_fib_get_table(id, 0) == NULL)
|
||||
return dn_fib_get_table(id, 1);
|
||||
return NULL;
|
||||
return dn_fib_get_table(id, 1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void dn_fib_flush(void)
|
||||
{
|
||||
int flushed = 0;
|
||||
struct dn_fib_table *tb;
|
||||
int flushed = 0;
|
||||
struct dn_fib_table *tb;
|
||||
struct hlist_node *node;
|
||||
unsigned int h;
|
||||
|
||||
for (h = 0; h < DN_FIB_TABLE_HASHSZ; h++) {
|
||||
hlist_for_each_entry(tb, node, &dn_fib_table_hash[h], hlist)
|
||||
flushed += tb->flush(tb);
|
||||
}
|
||||
flushed += tb->flush(tb);
|
||||
}
|
||||
|
||||
if (flushed)
|
||||
dn_rt_cache_flush(-1);
|
||||
if (flushed)
|
||||
dn_rt_cache_flush(-1);
|
||||
}
|
||||
|
||||
void __init dn_fib_table_init(void)
|
||||
@ -894,7 +894,7 @@ void __exit dn_fib_table_cleanup(void)
|
||||
write_lock(&dn_fib_tables_lock);
|
||||
for (h = 0; h < DN_FIB_TABLE_HASHSZ; h++) {
|
||||
hlist_for_each_entry_safe(t, node, next, &dn_fib_table_hash[h],
|
||||
hlist) {
|
||||
hlist) {
|
||||
hlist_del(&t->hlist);
|
||||
kfree(t);
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ static int __init dn_rtmsg_init(void)
|
||||
int rv = 0;
|
||||
|
||||
dnrmg = netlink_kernel_create(NETLINK_DNRTMSG, DNRNG_NLGRP_MAX,
|
||||
dnrmg_receive_user_sk, THIS_MODULE);
|
||||
dnrmg_receive_user_sk, THIS_MODULE);
|
||||
if (dnrmg == NULL) {
|
||||
printk(KERN_ERR "dn_rtmsg: Cannot create netlink socket");
|
||||
return -ENOMEM;
|
||||
|
@ -432,32 +432,32 @@ static ctl_table dn_table[] = {
|
||||
.extra2 = &max_decnet_no_fc_max_cwnd
|
||||
},
|
||||
{
|
||||
.ctl_name = NET_DECNET_MEM,
|
||||
.procname = "decnet_mem",
|
||||
.data = &sysctl_decnet_mem,
|
||||
.maxlen = sizeof(sysctl_decnet_mem),
|
||||
.mode = 0644,
|
||||
.proc_handler = &proc_dointvec,
|
||||
.strategy = &sysctl_intvec,
|
||||
},
|
||||
{
|
||||
.ctl_name = NET_DECNET_RMEM,
|
||||
.procname = "decnet_rmem",
|
||||
.data = &sysctl_decnet_rmem,
|
||||
.maxlen = sizeof(sysctl_decnet_rmem),
|
||||
.mode = 0644,
|
||||
.proc_handler = &proc_dointvec,
|
||||
.strategy = &sysctl_intvec,
|
||||
},
|
||||
{
|
||||
.ctl_name = NET_DECNET_WMEM,
|
||||
.procname = "decnet_wmem",
|
||||
.data = &sysctl_decnet_wmem,
|
||||
.maxlen = sizeof(sysctl_decnet_wmem),
|
||||
.mode = 0644,
|
||||
.proc_handler = &proc_dointvec,
|
||||
.strategy = &sysctl_intvec,
|
||||
},
|
||||
.ctl_name = NET_DECNET_MEM,
|
||||
.procname = "decnet_mem",
|
||||
.data = &sysctl_decnet_mem,
|
||||
.maxlen = sizeof(sysctl_decnet_mem),
|
||||
.mode = 0644,
|
||||
.proc_handler = &proc_dointvec,
|
||||
.strategy = &sysctl_intvec,
|
||||
},
|
||||
{
|
||||
.ctl_name = NET_DECNET_RMEM,
|
||||
.procname = "decnet_rmem",
|
||||
.data = &sysctl_decnet_rmem,
|
||||
.maxlen = sizeof(sysctl_decnet_rmem),
|
||||
.mode = 0644,
|
||||
.proc_handler = &proc_dointvec,
|
||||
.strategy = &sysctl_intvec,
|
||||
},
|
||||
{
|
||||
.ctl_name = NET_DECNET_WMEM,
|
||||
.procname = "decnet_wmem",
|
||||
.data = &sysctl_decnet_wmem,
|
||||
.maxlen = sizeof(sysctl_decnet_wmem),
|
||||
.mode = 0644,
|
||||
.proc_handler = &proc_dointvec,
|
||||
.strategy = &sysctl_intvec,
|
||||
},
|
||||
{
|
||||
.ctl_name = NET_DECNET_DEBUG_LEVEL,
|
||||
.procname = "debug",
|
||||
|
Loading…
Reference in New Issue
Block a user