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

Merge bk://kernel.bkbits.net/acme/net-2.5

into nuts.ninka.net:/home/davem/src/BK/net-2.5
parents 8f8495e9 95dcaa76
...@@ -415,7 +415,7 @@ static int ipxitf_demux_socket(struct ipx_interface *intrfc, ...@@ -415,7 +415,7 @@ static int ipxitf_demux_socket(struct ipx_interface *intrfc,
int is_broadcast = !memcmp(ipx->ipx_dest.node, ipx_broadcast_node, int is_broadcast = !memcmp(ipx->ipx_dest.node, ipx_broadcast_node,
IPX_NODE_LEN); IPX_NODE_LEN);
struct sock *s; struct sock *s;
int ret; int rc;
spin_lock_bh(&intrfc->if_sklist_lock); spin_lock_bh(&intrfc->if_sklist_lock);
s = intrfc->if_sklist; s = intrfc->if_sklist;
...@@ -431,7 +431,7 @@ static int ipxitf_demux_socket(struct ipx_interface *intrfc, ...@@ -431,7 +431,7 @@ static int ipxitf_demux_socket(struct ipx_interface *intrfc,
if (copy) { if (copy) {
skb1 = skb_clone(skb, GFP_ATOMIC); skb1 = skb_clone(skb, GFP_ATOMIC);
ret = -ENOMEM; rc = -ENOMEM;
if (!skb1) if (!skb1)
goto out; goto out;
} else { } else {
...@@ -451,10 +451,10 @@ static int ipxitf_demux_socket(struct ipx_interface *intrfc, ...@@ -451,10 +451,10 @@ static int ipxitf_demux_socket(struct ipx_interface *intrfc,
if (!copy) if (!copy)
kfree_skb(skb); kfree_skb(skb);
ret = 0; rc = 0;
out: out:
spin_unlock_bh(&intrfc->if_sklist_lock); spin_unlock_bh(&intrfc->if_sklist_lock);
return ret; return rc;
} }
#else #else
static struct sock *ncp_connection_hack(struct ipx_interface *intrfc, static struct sock *ncp_connection_hack(struct ipx_interface *intrfc,
...@@ -497,7 +497,7 @@ static int ipxitf_demux_socket(struct ipx_interface *intrfc, ...@@ -497,7 +497,7 @@ static int ipxitf_demux_socket(struct ipx_interface *intrfc,
struct ipxhdr *ipx = ipx_hdr(skb); struct ipxhdr *ipx = ipx_hdr(skb);
struct sock *sock1 = NULL, *sock2 = NULL; struct sock *sock1 = NULL, *sock2 = NULL;
struct sk_buff *skb1 = NULL, *skb2 = NULL; struct sk_buff *skb1 = NULL, *skb2 = NULL;
int ret; int rc;
if (intrfc == ipx_primary_net && ntohs(ipx->ipx_dest.sock) == 0x451) if (intrfc == ipx_primary_net && ntohs(ipx->ipx_dest.sock) == 0x451)
sock1 = ncp_connection_hack(intrfc, ipx); sock1 = ncp_connection_hack(intrfc, ipx);
...@@ -528,10 +528,11 @@ static int ipxitf_demux_socket(struct ipx_interface *intrfc, ...@@ -528,10 +528,11 @@ static int ipxitf_demux_socket(struct ipx_interface *intrfc,
/* /*
* If there is nothing to do return. The kfree will cancel any charging. * If there is nothing to do return. The kfree will cancel any charging.
*/ */
rc = 0;
if (!sock1 && !sock2) { if (!sock1 && !sock2) {
if (!copy) if (!copy)
kfree_skb(skb); kfree_skb(skb);
return 0; goto out;
} }
/* /*
...@@ -547,9 +548,9 @@ static int ipxitf_demux_socket(struct ipx_interface *intrfc, ...@@ -547,9 +548,9 @@ static int ipxitf_demux_socket(struct ipx_interface *intrfc,
else else
skb1 = skb; skb1 = skb;
ret = -ENOMEM; rc = -ENOMEM;
if (!skb1) if (!skb1)
goto out; goto out_put;
/* Do we need 2 SKBs? */ /* Do we need 2 SKBs? */
if (sock1 && sock2) if (sock1 && sock2)
...@@ -560,20 +561,20 @@ static int ipxitf_demux_socket(struct ipx_interface *intrfc, ...@@ -560,20 +561,20 @@ static int ipxitf_demux_socket(struct ipx_interface *intrfc,
if (sock1) if (sock1)
ipxitf_def_skb_handler(sock1, skb1); ipxitf_def_skb_handler(sock1, skb1);
ret = -ENOMEM;
if (!skb2) if (!skb2)
goto out; goto out_put;
if (sock2) if (sock2)
ipxitf_def_skb_handler(sock2, skb2); ipxitf_def_skb_handler(sock2, skb2);
ret = 0; rc = 0;
out: out_put:
if (sock1) if (sock1)
sock_put(sock1); sock_put(sock1);
if (sock2) if (sock2)
sock_put(sock2); sock_put(sock2);
return ret; out:
return rc;
} }
#endif /* CONFIG_IPX_INTERN */ #endif /* CONFIG_IPX_INTERN */
...@@ -727,7 +728,7 @@ static int ipxrtr_route_skb(struct sk_buff *skb); ...@@ -727,7 +728,7 @@ static int ipxrtr_route_skb(struct sk_buff *skb);
static int ipxitf_rcv(struct ipx_interface *intrfc, struct sk_buff *skb) static int ipxitf_rcv(struct ipx_interface *intrfc, struct sk_buff *skb)
{ {
struct ipxhdr *ipx = ipx_hdr(skb); struct ipxhdr *ipx = ipx_hdr(skb);
int ret = 0; int rc = 0;
ipxitf_hold(intrfc); ipxitf_hold(intrfc);
...@@ -737,8 +738,8 @@ static int ipxitf_rcv(struct ipx_interface *intrfc, struct sk_buff *skb) ...@@ -737,8 +738,8 @@ static int ipxitf_rcv(struct ipx_interface *intrfc, struct sk_buff *skb)
IPX_SKB_CB(skb)->last_hop.index = -1; IPX_SKB_CB(skb)->last_hop.index = -1;
if (ipx->ipx_type == IPX_TYPE_PPROP) { if (ipx->ipx_type == IPX_TYPE_PPROP) {
ret = ipxitf_pprop(intrfc, skb); rc = ipxitf_pprop(intrfc, skb);
if (ret) if (rc)
goto out_free_skb; goto out_free_skb;
} }
...@@ -756,7 +757,7 @@ static int ipxitf_rcv(struct ipx_interface *intrfc, struct sk_buff *skb) ...@@ -756,7 +757,7 @@ static int ipxitf_rcv(struct ipx_interface *intrfc, struct sk_buff *skb)
if (skb->pkt_type == PACKET_HOST) { if (skb->pkt_type == PACKET_HOST) {
skb = skb_unshare(skb, GFP_ATOMIC); skb = skb_unshare(skb, GFP_ATOMIC);
if (skb) if (skb)
ret = ipxrtr_route_skb(skb); rc = ipxrtr_route_skb(skb);
goto out_intrfc; goto out_intrfc;
} }
...@@ -766,7 +767,7 @@ static int ipxitf_rcv(struct ipx_interface *intrfc, struct sk_buff *skb) ...@@ -766,7 +767,7 @@ static int ipxitf_rcv(struct ipx_interface *intrfc, struct sk_buff *skb)
/* see if we should keep it */ /* see if we should keep it */
if (!memcmp(ipx_broadcast_node, ipx->ipx_dest.node, IPX_NODE_LEN) || if (!memcmp(ipx_broadcast_node, ipx->ipx_dest.node, IPX_NODE_LEN) ||
!memcmp(intrfc->if_node, ipx->ipx_dest.node, IPX_NODE_LEN)) { !memcmp(intrfc->if_node, ipx->ipx_dest.node, IPX_NODE_LEN)) {
ret = ipxitf_demux_socket(intrfc, skb, 0); rc = ipxitf_demux_socket(intrfc, skb, 0);
goto out_intrfc; goto out_intrfc;
} }
...@@ -775,7 +776,7 @@ static int ipxitf_rcv(struct ipx_interface *intrfc, struct sk_buff *skb) ...@@ -775,7 +776,7 @@ static int ipxitf_rcv(struct ipx_interface *intrfc, struct sk_buff *skb)
kfree_skb(skb); kfree_skb(skb);
out_intrfc: out_intrfc:
ipxitf_put(intrfc); ipxitf_put(intrfc);
return ret; return rc;
} }
static void ipxitf_discover_netnum(struct ipx_interface *intrfc, static void ipxitf_discover_netnum(struct ipx_interface *intrfc,
...@@ -833,7 +834,7 @@ static void ipxitf_discover_netnum(struct ipx_interface *intrfc, ...@@ -833,7 +834,7 @@ static void ipxitf_discover_netnum(struct ipx_interface *intrfc,
static int ipxitf_pprop(struct ipx_interface *intrfc, struct sk_buff *skb) static int ipxitf_pprop(struct ipx_interface *intrfc, struct sk_buff *skb)
{ {
struct ipxhdr *ipx = ipx_hdr(skb); struct ipxhdr *ipx = ipx_hdr(skb);
int i, ret = -EINVAL; int i, rc = -EINVAL;
struct ipx_interface *ifcs; struct ipx_interface *ifcs;
char *c; char *c;
u32 *l; u32 *l;
...@@ -847,7 +848,7 @@ static int ipxitf_pprop(struct ipx_interface *intrfc, struct sk_buff *skb) ...@@ -847,7 +848,7 @@ static int ipxitf_pprop(struct ipx_interface *intrfc, struct sk_buff *skb)
IPX_MAX_PPROP_HOPS * sizeof(u32)) IPX_MAX_PPROP_HOPS * sizeof(u32))
goto out; goto out;
/* are we broadcasting this damn thing? */ /* are we broadcasting this damn thing? */
ret = 0; rc = 0;
if (!sysctl_ipx_pprop_broadcasting) if (!sysctl_ipx_pprop_broadcasting)
goto out; goto out;
/* We do broadcast packet on the IPX_MAX_PPROP_HOPS hop, but we /* We do broadcast packet on the IPX_MAX_PPROP_HOPS hop, but we
...@@ -896,7 +897,7 @@ static int ipxitf_pprop(struct ipx_interface *intrfc, struct sk_buff *skb) ...@@ -896,7 +897,7 @@ static int ipxitf_pprop(struct ipx_interface *intrfc, struct sk_buff *skb)
} }
spin_unlock_bh(&ipx_interfaces_lock); spin_unlock_bh(&ipx_interfaces_lock);
out: out:
return ret; return rc;
} }
static void ipxitf_insert(struct ipx_interface *intrfc) static void ipxitf_insert(struct ipx_interface *intrfc)
...@@ -944,24 +945,24 @@ static struct ipx_interface *ipxitf_alloc(struct net_device *dev, __u32 netnum, ...@@ -944,24 +945,24 @@ static struct ipx_interface *ipxitf_alloc(struct net_device *dev, __u32 netnum,
static int ipxitf_create_internal(struct ipx_interface_definition *idef) static int ipxitf_create_internal(struct ipx_interface_definition *idef)
{ {
struct ipx_interface *intrfc; struct ipx_interface *intrfc;
int ret = -EEXIST; int rc = -EEXIST;
/* Only one primary network allowed */ /* Only one primary network allowed */
if (ipx_primary_net) if (ipx_primary_net)
goto out; goto out;
/* Must have a valid network number */ /* Must have a valid network number */
ret = -EADDRNOTAVAIL; rc = -EADDRNOTAVAIL;
if (!idef->ipx_network) if (!idef->ipx_network)
goto out; goto out;
intrfc = ipxitf_find_using_net(idef->ipx_network); intrfc = ipxitf_find_using_net(idef->ipx_network);
ret = -EADDRINUSE; rc = -EADDRINUSE;
if (intrfc) { if (intrfc) {
ipxitf_put(intrfc); ipxitf_put(intrfc);
goto out; goto out;
} }
intrfc = ipxitf_alloc(NULL, idef->ipx_network, 0, NULL, 1, 0); intrfc = ipxitf_alloc(NULL, idef->ipx_network, 0, NULL, 1, 0);
ret = -EAGAIN; rc = -EAGAIN;
if (!intrfc) if (!intrfc)
goto out; goto out;
memcpy((char *)&(intrfc->if_node), idef->ipx_node, IPX_NODE_LEN); memcpy((char *)&(intrfc->if_node), idef->ipx_node, IPX_NODE_LEN);
...@@ -969,28 +970,24 @@ static int ipxitf_create_internal(struct ipx_interface_definition *idef) ...@@ -969,28 +970,24 @@ static int ipxitf_create_internal(struct ipx_interface_definition *idef)
ipxitf_hold(intrfc); ipxitf_hold(intrfc);
ipxitf_insert(intrfc); ipxitf_insert(intrfc);
ret = ipxitf_add_local_route(intrfc); rc = ipxitf_add_local_route(intrfc);
ipxitf_put(intrfc); ipxitf_put(intrfc);
out: out:
return ret; return rc;
} }
static int ipx_map_frame_type(unsigned char type) static int ipx_map_frame_type(unsigned char type)
{ {
int ret = 0; int rc = 0;
switch (type) { switch (type) {
case IPX_FRAME_ETHERII: case IPX_FRAME_ETHERII: rc = htons(ETH_P_IPX); break;
ret = htons(ETH_P_IPX); break; case IPX_FRAME_8022: rc = htons(ETH_P_802_2); break;
case IPX_FRAME_8022: case IPX_FRAME_SNAP: rc = htons(ETH_P_SNAP); break;
ret = htons(ETH_P_802_2); break; case IPX_FRAME_8023: rc = htons(ETH_P_802_3); break;
case IPX_FRAME_SNAP:
ret = htons(ETH_P_SNAP); break;
case IPX_FRAME_8023:
ret = htons(ETH_P_802_3); break;
} }
return ret; return rc;
} }
static int ipxitf_create(struct ipx_interface_definition *idef) static int ipxitf_create(struct ipx_interface_definition *idef)
...@@ -999,19 +996,19 @@ static int ipxitf_create(struct ipx_interface_definition *idef) ...@@ -999,19 +996,19 @@ static int ipxitf_create(struct ipx_interface_definition *idef)
unsigned short dlink_type = 0; unsigned short dlink_type = 0;
struct datalink_proto *datalink = NULL; struct datalink_proto *datalink = NULL;
struct ipx_interface *intrfc; struct ipx_interface *intrfc;
int err; int rc;
if (idef->ipx_special == IPX_INTERNAL) { if (idef->ipx_special == IPX_INTERNAL) {
err = ipxitf_create_internal(idef); rc = ipxitf_create_internal(idef);
goto out; goto out;
} }
err = -EEXIST; rc = -EEXIST;
if (idef->ipx_special == IPX_PRIMARY && ipx_primary_net) if (idef->ipx_special == IPX_PRIMARY && ipx_primary_net)
goto out; goto out;
intrfc = ipxitf_find_using_net(idef->ipx_network); intrfc = ipxitf_find_using_net(idef->ipx_network);
err = -EADDRINUSE; rc = -EADDRINUSE;
if (idef->ipx_network && intrfc) { if (idef->ipx_network && intrfc) {
ipxitf_put(intrfc); ipxitf_put(intrfc);
goto out; goto out;
...@@ -1021,7 +1018,7 @@ static int ipxitf_create(struct ipx_interface_definition *idef) ...@@ -1021,7 +1018,7 @@ static int ipxitf_create(struct ipx_interface_definition *idef)
ipxitf_put(intrfc); ipxitf_put(intrfc);
dev = dev_get_by_name(idef->ipx_device); dev = dev_get_by_name(idef->ipx_device);
err = -ENODEV; rc = -ENODEV;
if (!dev) if (!dev)
goto out; goto out;
...@@ -1040,8 +1037,8 @@ static int ipxitf_create(struct ipx_interface_definition *idef) ...@@ -1040,8 +1037,8 @@ static int ipxitf_create(struct ipx_interface_definition *idef)
datalink = pEII_datalink; datalink = pEII_datalink;
break; break;
} else } else
printk(KERN_WARNING "IPX frame type EtherII " printk(KERN_WARNING "IPX frame type EtherII over "
"over token-ring is obsolete. Use SNAP " "token-ring is obsolete. Use SNAP "
"instead.\n"); "instead.\n");
/* fall through */ /* fall through */
case IPX_FRAME_SNAP: case IPX_FRAME_SNAP:
...@@ -1054,16 +1051,16 @@ static int ipxitf_create(struct ipx_interface_definition *idef) ...@@ -1054,16 +1051,16 @@ static int ipxitf_create(struct ipx_interface_definition *idef)
break; break;
case IPX_FRAME_NONE: case IPX_FRAME_NONE:
default: default:
err = -EPROTONOSUPPORT; rc = -EPROTONOSUPPORT;
goto out_dev; goto out_dev;
} }
err = -ENETDOWN; rc = -ENETDOWN;
if (!(dev->flags & IFF_UP)) if (!(dev->flags & IFF_UP))
goto out_dev; goto out_dev;
/* Check addresses are suitable */ /* Check addresses are suitable */
err = -EINVAL; rc = -EINVAL;
if (dev->addr_len > IPX_NODE_LEN) if (dev->addr_len > IPX_NODE_LEN)
goto out_dev; goto out_dev;
...@@ -1073,7 +1070,7 @@ static int ipxitf_create(struct ipx_interface_definition *idef) ...@@ -1073,7 +1070,7 @@ static int ipxitf_create(struct ipx_interface_definition *idef)
intrfc = ipxitf_alloc(dev, idef->ipx_network, dlink_type, intrfc = ipxitf_alloc(dev, idef->ipx_network, dlink_type,
datalink, 0, dev->hard_header_len + datalink, 0, dev->hard_header_len +
datalink->header_length); datalink->header_length);
err = -EAGAIN; rc = -EAGAIN;
if (!intrfc) if (!intrfc)
goto out_dev; goto out_dev;
/* Setup primary if necessary */ /* Setup primary if necessary */
...@@ -1092,18 +1089,18 @@ static int ipxitf_create(struct ipx_interface_definition *idef) ...@@ -1092,18 +1089,18 @@ static int ipxitf_create(struct ipx_interface_definition *idef)
/* If the network number is known, add a route */ /* If the network number is known, add a route */
err = 0; rc = 0;
if (!intrfc->if_netnum) if (!intrfc->if_netnum)
goto out_intrfc; goto out_intrfc;
err = ipxitf_add_local_route(intrfc); rc = ipxitf_add_local_route(intrfc);
out_intrfc: out_intrfc:
ipxitf_put(intrfc); ipxitf_put(intrfc);
goto out; goto out;
out_dev: out_dev:
dev_put(dev); dev_put(dev);
out: out:
return err; return rc;
} }
static int ipxitf_delete(struct ipx_interface_definition *idef) static int ipxitf_delete(struct ipx_interface_definition *idef)
...@@ -1111,7 +1108,7 @@ static int ipxitf_delete(struct ipx_interface_definition *idef) ...@@ -1111,7 +1108,7 @@ static int ipxitf_delete(struct ipx_interface_definition *idef)
struct net_device *dev = NULL; struct net_device *dev = NULL;
unsigned short dlink_type = 0; unsigned short dlink_type = 0;
struct ipx_interface *intrfc; struct ipx_interface *intrfc;
int ret = 0; int rc = 0;
spin_lock_bh(&ipx_interfaces_lock); spin_lock_bh(&ipx_interfaces_lock);
if (idef->ipx_special == IPX_INTERNAL) { if (idef->ipx_special == IPX_INTERNAL) {
...@@ -1119,30 +1116,30 @@ static int ipxitf_delete(struct ipx_interface_definition *idef) ...@@ -1119,30 +1116,30 @@ static int ipxitf_delete(struct ipx_interface_definition *idef)
__ipxitf_put(ipx_internal_net); __ipxitf_put(ipx_internal_net);
goto out; goto out;
} }
ret = -ENOENT; rc = -ENOENT;
goto out; goto out;
} }
dlink_type = ipx_map_frame_type(idef->ipx_dlink_type); dlink_type = ipx_map_frame_type(idef->ipx_dlink_type);
ret = -EPROTONOSUPPORT; rc = -EPROTONOSUPPORT;
if (!dlink_type) if (!dlink_type)
goto out; goto out;
dev = __dev_get_by_name(idef->ipx_device); dev = __dev_get_by_name(idef->ipx_device);
ret = -ENODEV; rc = -ENODEV;
if (!dev) if (!dev)
goto out; goto out;
intrfc = __ipxitf_find_using_phys(dev, dlink_type); intrfc = __ipxitf_find_using_phys(dev, dlink_type);
ret = -EINVAL; rc = -EINVAL;
if (!intrfc) if (!intrfc)
goto out; goto out;
__ipxitf_put(intrfc); __ipxitf_put(intrfc);
ret = 0; rc = 0;
out: out:
spin_unlock_bh(&ipx_interfaces_lock); spin_unlock_bh(&ipx_interfaces_lock);
return ret; return rc;
} }
static struct ipx_interface *ipxitf_auto_create(struct net_device *dev, static struct ipx_interface *ipxitf_auto_create(struct net_device *dev,
...@@ -1159,24 +1156,11 @@ static struct ipx_interface *ipxitf_auto_create(struct net_device *dev, ...@@ -1159,24 +1156,11 @@ static struct ipx_interface *ipxitf_auto_create(struct net_device *dev,
goto out; goto out;
switch (htons(dlink_type)) { switch (htons(dlink_type)) {
case ETH_P_IPX: case ETH_P_IPX: datalink = pEII_datalink; break;
datalink = pEII_datalink; case ETH_P_802_2: datalink = p8022_datalink; break;
break; case ETH_P_SNAP: datalink = pSNAP_datalink; break;
case ETH_P_802_3: datalink = p8023_datalink; break;
case ETH_P_802_2: default: goto out;
datalink = p8022_datalink;
break;
case ETH_P_SNAP:
datalink = pSNAP_datalink;
break;
case ETH_P_802_3:
datalink = p8023_datalink;
break;
default:
goto out;
} }
intrfc = ipxitf_alloc(dev, 0, dlink_type, datalink, 0, intrfc = ipxitf_alloc(dev, 0, dlink_type, datalink, 0,
...@@ -1198,6 +1182,7 @@ static struct ipx_interface *ipxitf_auto_create(struct net_device *dev, ...@@ -1198,6 +1182,7 @@ static struct ipx_interface *ipxitf_auto_create(struct net_device *dev,
static int ipxitf_ioctl(unsigned int cmd, void *arg) static int ipxitf_ioctl(unsigned int cmd, void *arg)
{ {
int rc = -EINVAL;
struct ifreq ifr; struct ifreq ifr;
int val; int val;
...@@ -1206,13 +1191,13 @@ static int ipxitf_ioctl(unsigned int cmd, void *arg) ...@@ -1206,13 +1191,13 @@ static int ipxitf_ioctl(unsigned int cmd, void *arg)
struct sockaddr_ipx *sipx; struct sockaddr_ipx *sipx;
struct ipx_interface_definition f; struct ipx_interface_definition f;
rc = -EFAULT;
if (copy_from_user(&ifr, arg, sizeof(ifr))) if (copy_from_user(&ifr, arg, sizeof(ifr)))
return -EFAULT; break;
sipx = (struct sockaddr_ipx *)&ifr.ifr_addr; sipx = (struct sockaddr_ipx *)&ifr.ifr_addr;
rc = -EINVAL;
if (sipx->sipx_family != AF_IPX) if (sipx->sipx_family != AF_IPX)
return -EINVAL; break;
f.ipx_network = sipx->sipx_network; f.ipx_network = sipx->sipx_network;
memcpy(f.ipx_device, ifr.ifr_name, memcpy(f.ipx_device, ifr.ifr_name,
sizeof(f.ipx_device)); sizeof(f.ipx_device));
...@@ -1221,57 +1206,58 @@ static int ipxitf_ioctl(unsigned int cmd, void *arg) ...@@ -1221,57 +1206,58 @@ static int ipxitf_ioctl(unsigned int cmd, void *arg)
f.ipx_special = sipx->sipx_special; f.ipx_special = sipx->sipx_special;
if (sipx->sipx_action == IPX_DLTITF) if (sipx->sipx_action == IPX_DLTITF)
return ipxitf_delete(&f); rc = ipxitf_delete(&f);
else else
return ipxitf_create(&f); rc = ipxitf_create(&f);
break;
} }
case SIOCGIFADDR: { case SIOCGIFADDR: {
int err = 0;
struct sockaddr_ipx *sipx; struct sockaddr_ipx *sipx;
struct ipx_interface *ipxif; struct ipx_interface *ipxif;
struct net_device *dev; struct net_device *dev;
rc = -EFAULT;
if (copy_from_user(&ifr, arg, sizeof(ifr))) if (copy_from_user(&ifr, arg, sizeof(ifr)))
return -EFAULT; break;
sipx = (struct sockaddr_ipx *)&ifr.ifr_addr; sipx = (struct sockaddr_ipx *)&ifr.ifr_addr;
dev = __dev_get_by_name(ifr.ifr_name); dev = __dev_get_by_name(ifr.ifr_name);
rc = -ENODEV;
if (!dev) if (!dev)
return -ENODEV; break;
ipxif = ipxitf_find_using_phys(dev,
ipxif = ipxitf_find_using_phys(dev, ipx_map_frame_type(sipx->sipx_type)); ipx_map_frame_type(sipx->sipx_type));
rc = -EADDRNOTAVAIL;
if (!ipxif) if (!ipxif)
return -EADDRNOTAVAIL; break;
sipx->sipx_family = AF_IPX; sipx->sipx_family = AF_IPX;
sipx->sipx_network = ipxif->if_netnum; sipx->sipx_network = ipxif->if_netnum;
memcpy(sipx->sipx_node, ipxif->if_node, memcpy(sipx->sipx_node, ipxif->if_node,
sizeof(sipx->sipx_node)); sizeof(sipx->sipx_node));
rc = -EFAULT;
if (copy_to_user(arg, &ifr, sizeof(ifr))) if (copy_to_user(arg, &ifr, sizeof(ifr)))
err = -EFAULT; break;
ipxitf_put(ipxif); ipxitf_put(ipxif);
return err; rc = 0;
break;
} }
case SIOCAIPXITFCRT: case SIOCAIPXITFCRT:
rc = -EFAULT;
if (get_user(val, (unsigned char *) arg)) if (get_user(val, (unsigned char *) arg))
return -EFAULT; break;
rc = 0;
ipxcfg_auto_create_interfaces = val; ipxcfg_auto_create_interfaces = val;
break; break;
case SIOCAIPXPRISLT: case SIOCAIPXPRISLT:
rc = -EFAULT;
if (get_user(val, (unsigned char *) arg)) if (get_user(val, (unsigned char *) arg))
return -EFAULT; break;
rc = 0;
ipxcfg_set_auto_select(val); ipxcfg_set_auto_select(val);
break; break;
default:
return -EINVAL;
} }
return 0; return rc;
} }
/* Routing tables for the IPX socket layer. */ /* Routing tables for the IPX socket layer. */
...@@ -1307,13 +1293,13 @@ static int ipxrtr_add_route(__u32 network, struct ipx_interface *intrfc, ...@@ -1307,13 +1293,13 @@ static int ipxrtr_add_route(__u32 network, struct ipx_interface *intrfc,
unsigned char *node) unsigned char *node)
{ {
struct ipx_route *rt; struct ipx_route *rt;
int ret; int rc;
/* Get a route structure; either existing or create */ /* Get a route structure; either existing or create */
rt = ipxrtr_lookup(network); rt = ipxrtr_lookup(network);
if (!rt) { if (!rt) {
rt = kmalloc(sizeof(*rt), GFP_ATOMIC); rt = kmalloc(sizeof(*rt), GFP_ATOMIC);
ret = -EAGAIN; rc = -EAGAIN;
if (!rt) if (!rt)
goto out; goto out;
...@@ -1324,7 +1310,7 @@ static int ipxrtr_add_route(__u32 network, struct ipx_interface *intrfc, ...@@ -1324,7 +1310,7 @@ static int ipxrtr_add_route(__u32 network, struct ipx_interface *intrfc,
ipx_routes = rt; ipx_routes = rt;
write_unlock_bh(&ipx_routes_lock); write_unlock_bh(&ipx_routes_lock);
} else { } else {
ret = -EEXIST; rc = -EEXIST;
if (intrfc == ipx_internal_net) if (intrfc == ipx_internal_net)
goto out_put; goto out_put;
} }
...@@ -1339,11 +1325,11 @@ static int ipxrtr_add_route(__u32 network, struct ipx_interface *intrfc, ...@@ -1339,11 +1325,11 @@ static int ipxrtr_add_route(__u32 network, struct ipx_interface *intrfc,
rt->ir_routed = 1; rt->ir_routed = 1;
} }
ret = 0; rc = 0;
out_put: out_put:
ipxrtr_put(rt); ipxrtr_put(rt);
out: out:
return ret; return rc;
} }
static void ipxrtr_del_routes(struct ipx_interface *intrfc) static void ipxrtr_del_routes(struct ipx_interface *intrfc)
...@@ -1364,44 +1350,44 @@ static void ipxrtr_del_routes(struct ipx_interface *intrfc) ...@@ -1364,44 +1350,44 @@ static void ipxrtr_del_routes(struct ipx_interface *intrfc)
static int ipxrtr_create(struct ipx_route_definition *rd) static int ipxrtr_create(struct ipx_route_definition *rd)
{ {
struct ipx_interface *intrfc; struct ipx_interface *intrfc;
int ret = -ENETUNREACH; int rc = -ENETUNREACH;
/* Find the appropriate interface */ /* Find the appropriate interface */
intrfc = ipxitf_find_using_net(rd->ipx_router_network); intrfc = ipxitf_find_using_net(rd->ipx_router_network);
if (!intrfc) if (!intrfc)
goto out; goto out;
ret = ipxrtr_add_route(rd->ipx_network, intrfc, rd->ipx_router_node); rc = ipxrtr_add_route(rd->ipx_network, intrfc, rd->ipx_router_node);
ipxitf_put(intrfc); ipxitf_put(intrfc);
out: out:
return ret; return rc;
} }
static int ipxrtr_delete(long net) static int ipxrtr_delete(long net)
{ {
struct ipx_route **r; struct ipx_route **r;
struct ipx_route *tmp; struct ipx_route *tmp;
int err; int rc;
write_lock_bh(&ipx_routes_lock); write_lock_bh(&ipx_routes_lock);
for (r = &ipx_routes; (tmp = *r) != NULL;) { for (r = &ipx_routes; (tmp = *r) != NULL;) {
if (tmp->ir_net == net) { if (tmp->ir_net == net) {
/* Directly connected; can't lose route */ /* Directly connected; can't lose route */
err = -EPERM; rc = -EPERM;
if (!tmp->ir_routed) if (!tmp->ir_routed)
goto out; goto out;
*r = tmp->ir_next; *r = tmp->ir_next;
ipxrtr_put(tmp); ipxrtr_put(tmp);
err = 0; rc = 0;
goto out; goto out;
} }
r = &(tmp->ir_next); r = &(tmp->ir_next);
} }
err = -ENOENT; rc = -ENOENT;
out: out:
write_unlock_bh(&ipx_routes_lock); write_unlock_bh(&ipx_routes_lock);
return err; return rc;
} }
/* /*
...@@ -1456,7 +1442,7 @@ static int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx, ...@@ -1456,7 +1442,7 @@ static int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
int size; int size;
int ipx_offset; int ipx_offset;
struct ipx_route *rt = NULL; struct ipx_route *rt = NULL;
int err; int rc;
/* Find the appropriate interface on which to send packet */ /* Find the appropriate interface on which to send packet */
if (!usipx->sipx_network && ipx_primary_net) { if (!usipx->sipx_network && ipx_primary_net) {
...@@ -1464,7 +1450,7 @@ static int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx, ...@@ -1464,7 +1450,7 @@ static int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
intrfc = ipx_primary_net; intrfc = ipx_primary_net;
} else { } else {
rt = ipxrtr_lookup(usipx->sipx_network); rt = ipxrtr_lookup(usipx->sipx_network);
err = -ENETUNREACH; rc = -ENETUNREACH;
if (!rt) if (!rt)
goto out; goto out;
intrfc = rt->ir_intrfc; intrfc = rt->ir_intrfc;
...@@ -1474,7 +1460,7 @@ static int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx, ...@@ -1474,7 +1460,7 @@ static int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
ipx_offset = intrfc->if_ipx_offset; ipx_offset = intrfc->if_ipx_offset;
size = sizeof(struct ipxhdr) + len + ipx_offset; size = sizeof(struct ipxhdr) + len + ipx_offset;
skb = sock_alloc_send_skb(sk, size, noblock, &err); skb = sock_alloc_send_skb(sk, size, noblock, &rc);
if (!skb) if (!skb)
goto out_put; goto out_put;
...@@ -1493,8 +1479,8 @@ static int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx, ...@@ -1493,8 +1479,8 @@ static int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
IPX_SKB_CB(skb)->ipx_source_net = ipxs->intrfc->if_netnum; IPX_SKB_CB(skb)->ipx_source_net = ipxs->intrfc->if_netnum;
memcpy(ipx->ipx_source.node, ipxs->node, IPX_NODE_LEN); memcpy(ipx->ipx_source.node, ipxs->node, IPX_NODE_LEN);
#else #else
err = ntohs(ipxs->port); rc = ntohs(ipxs->port);
if (err == 0x453 || err == 0x452) { if (rc == 0x453 || rc == 0x452) {
/* RIP/SAP special handling for mars_nwe */ /* RIP/SAP special handling for mars_nwe */
IPX_SKB_CB(skb)->ipx_source_net = intrfc->if_netnum; IPX_SKB_CB(skb)->ipx_source_net = intrfc->if_netnum;
memcpy(ipx->ipx_source.node, intrfc->if_node, IPX_NODE_LEN); memcpy(ipx->ipx_source.node, intrfc->if_node, IPX_NODE_LEN);
...@@ -1509,8 +1495,8 @@ static int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx, ...@@ -1509,8 +1495,8 @@ static int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
memcpy(ipx->ipx_dest.node, usipx->sipx_node, IPX_NODE_LEN); memcpy(ipx->ipx_dest.node, usipx->sipx_node, IPX_NODE_LEN);
ipx->ipx_dest.sock = usipx->sipx_port; ipx->ipx_dest.sock = usipx->sipx_port;
err = memcpy_fromiovec(skb_put(skb, len), iov, len); rc = memcpy_fromiovec(skb_put(skb, len), iov, len);
if (err) { if (rc) {
kfree_skb(skb); kfree_skb(skb);
goto out_put; goto out_put;
} }
...@@ -1521,14 +1507,14 @@ static int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx, ...@@ -1521,14 +1507,14 @@ static int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
else else
ipx->ipx_checksum = ipx_cksum(ipx, len + sizeof(struct ipxhdr)); ipx->ipx_checksum = ipx_cksum(ipx, len + sizeof(struct ipxhdr));
err = ipxitf_send(intrfc, skb, (rt && rt->ir_routed) ? rc = ipxitf_send(intrfc, skb, (rt && rt->ir_routed) ?
rt->ir_router_node : ipx->ipx_dest.node); rt->ir_router_node : ipx->ipx_dest.node);
out_put: out_put:
ipxitf_put(intrfc); ipxitf_put(intrfc);
if (rt) if (rt)
ipxrtr_put(rt); ipxrtr_put(rt);
out: out:
return err; return rc;
} }
/* the skb has to be unshared, we'll end up calling ipxitf_send, that'll /* the skb has to be unshared, we'll end up calling ipxitf_send, that'll
...@@ -1559,7 +1545,7 @@ static int ipxrtr_ioctl(unsigned int cmd, void *arg) ...@@ -1559,7 +1545,7 @@ static int ipxrtr_ioctl(unsigned int cmd, void *arg)
{ {
struct rtentry rt; /* Use these to behave like 'other' stacks */ struct rtentry rt; /* Use these to behave like 'other' stacks */
struct sockaddr_ipx *sg, *st; struct sockaddr_ipx *sg, *st;
int ret = -EFAULT; int rc = -EFAULT;
if (copy_from_user(&rt, arg, sizeof(rt))) if (copy_from_user(&rt, arg, sizeof(rt)))
goto out; goto out;
...@@ -1567,7 +1553,7 @@ static int ipxrtr_ioctl(unsigned int cmd, void *arg) ...@@ -1567,7 +1553,7 @@ static int ipxrtr_ioctl(unsigned int cmd, void *arg)
sg = (struct sockaddr_ipx *)&rt.rt_gateway; sg = (struct sockaddr_ipx *)&rt.rt_gateway;
st = (struct sockaddr_ipx *)&rt.rt_dst; st = (struct sockaddr_ipx *)&rt.rt_dst;
ret = -EINVAL; rc = -EINVAL;
if (!(rt.rt_flags & RTF_GATEWAY) || /* Direct routes are fixed */ if (!(rt.rt_flags & RTF_GATEWAY) || /* Direct routes are fixed */
sg->sipx_family != AF_IPX || sg->sipx_family != AF_IPX ||
st->sipx_family != AF_IPX) st->sipx_family != AF_IPX)
...@@ -1575,35 +1561,35 @@ static int ipxrtr_ioctl(unsigned int cmd, void *arg) ...@@ -1575,35 +1561,35 @@ static int ipxrtr_ioctl(unsigned int cmd, void *arg)
switch (cmd) { switch (cmd) {
case SIOCDELRT: case SIOCDELRT:
ret = ipxrtr_delete(st->sipx_network); rc = ipxrtr_delete(st->sipx_network);
break; break;
case SIOCADDRT: { case SIOCADDRT: {
struct ipx_route_definition f; struct ipx_route_definition f;
f.ipx_network = st->sipx_network; f.ipx_network = st->sipx_network;
f.ipx_router_network = sg->sipx_network; f.ipx_router_network = sg->sipx_network;
memcpy(f.ipx_router_node, sg->sipx_node, IPX_NODE_LEN); memcpy(f.ipx_router_node, sg->sipx_node, IPX_NODE_LEN);
ret = ipxrtr_create(&f); rc = ipxrtr_create(&f);
break; break;
} }
} }
out: out:
return ret; return rc;
} }
const char *ipx_frame_name(unsigned short frame) const char *ipx_frame_name(unsigned short frame)
{ {
char* ret = "None"; char* rc = "None";
switch (ntohs(frame)) { switch (ntohs(frame)) {
case ETH_P_IPX: ret = "EtherII"; break; case ETH_P_IPX: rc = "EtherII"; break;
case ETH_P_802_2: ret = "802.2"; break; case ETH_P_802_2: rc = "802.2"; break;
case ETH_P_SNAP: ret = "SNAP"; break; case ETH_P_SNAP: rc = "SNAP"; break;
case ETH_P_802_3: ret = "802.3"; break; case ETH_P_802_3: rc = "802.3"; break;
case ETH_P_TR_802_2: ret = "802.2TR"; break; case ETH_P_TR_802_2: rc = "802.2TR"; break;
} }
return ret; return rc;
} }
const char *ipx_device_name(struct ipx_interface *intrfc) const char *ipx_device_name(struct ipx_interface *intrfc)
...@@ -1620,23 +1606,23 @@ static int ipx_setsockopt(struct socket *sock, int level, int optname, ...@@ -1620,23 +1606,23 @@ static int ipx_setsockopt(struct socket *sock, int level, int optname,
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
int opt; int opt;
int ret = -EINVAL; int rc = -EINVAL;
if (optlen != sizeof(int)) if (optlen != sizeof(int))
goto out; goto out;
ret = -EFAULT; rc = -EFAULT;
if (get_user(opt, (unsigned int *)optval)) if (get_user(opt, (unsigned int *)optval))
goto out; goto out;
ret = -ENOPROTOOPT; rc = -ENOPROTOOPT;
if (!(level == SOL_IPX && optname == IPX_TYPE)) if (!(level == SOL_IPX && optname == IPX_TYPE))
goto out; goto out;
ipx_sk(sk)->type = opt; ipx_sk(sk)->type = opt;
ret = 0; rc = 0;
out: out:
return ret; return rc;
} }
static int ipx_getsockopt(struct socket *sock, int level, int optname, static int ipx_getsockopt(struct socket *sock, int level, int optname,
...@@ -1645,41 +1631,41 @@ static int ipx_getsockopt(struct socket *sock, int level, int optname, ...@@ -1645,41 +1631,41 @@ static int ipx_getsockopt(struct socket *sock, int level, int optname,
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
int val = 0; int val = 0;
int len; int len;
int ret = -ENOPROTOOPT; int rc = -ENOPROTOOPT;
if (!(level == SOL_IPX && optname == IPX_TYPE)) if (!(level == SOL_IPX && optname == IPX_TYPE))
goto out; goto out;
val = ipx_sk(sk)->type; val = ipx_sk(sk)->type;
ret = -EFAULT; rc = -EFAULT;
if (get_user(len, optlen)) if (get_user(len, optlen))
goto out; goto out;
len = min_t(unsigned int, len, sizeof(int)); len = min_t(unsigned int, len, sizeof(int));
ret = -EINVAL; rc = -EINVAL;
if(len < 0) if(len < 0)
goto out; goto out;
ret = -EFAULT; rc = -EFAULT;
if (put_user(len, optlen) || copy_to_user(optval, &val, len)) if (put_user(len, optlen) || copy_to_user(optval, &val, len))
goto out; goto out;
ret = 0; rc = 0;
out: out:
return ret; return rc;
} }
static int ipx_create(struct socket *sock, int protocol) static int ipx_create(struct socket *sock, int protocol)
{ {
int ret = -ESOCKTNOSUPPORT; int rc = -ESOCKTNOSUPPORT;
struct ipx_opt *ipx = NULL; struct ipx_opt *ipx = NULL;
struct sock *sk; struct sock *sk;
switch (sock->type) { switch (sock->type) {
case SOCK_DGRAM: case SOCK_DGRAM:
sk = sk_alloc(PF_IPX, GFP_KERNEL, 1, NULL); sk = sk_alloc(PF_IPX, GFP_KERNEL, 1, NULL);
ret = -ENOMEM; rc = -ENOMEM;
if (!sk) if (!sk)
goto out; goto out;
ipx = ipx_sk(sk) = kmalloc(sizeof(*ipx), GFP_KERNEL); ipx = ipx_sk(sk) = kmalloc(sizeof(*ipx), GFP_KERNEL);
...@@ -1688,7 +1674,6 @@ static int ipx_create(struct socket *sock, int protocol) ...@@ -1688,7 +1674,6 @@ static int ipx_create(struct socket *sock, int protocol)
memset(ipx, 0, sizeof(*ipx)); memset(ipx, 0, sizeof(*ipx));
sock->ops = &ipx_dgram_ops; sock->ops = &ipx_dgram_ops;
break; break;
case SOCK_SEQPACKET: case SOCK_SEQPACKET:
/* /*
* SPX support is not anymore in the kernel sources. If * SPX support is not anymore in the kernel sources. If
...@@ -1707,9 +1692,9 @@ static int ipx_create(struct socket *sock, int protocol) ...@@ -1707,9 +1692,9 @@ static int ipx_create(struct socket *sock, int protocol)
#endif #endif
sock_init_data(sock, sk); sock_init_data(sock, sk);
sk->no_check = 1; /* Checksum off by default */ sk->no_check = 1; /* Checksum off by default */
ret = 0; rc = 0;
out: out:
return ret; return rc;
outsk: outsk:
sk_free(sk); sk_free(sk);
goto out; goto out;
...@@ -1761,25 +1746,25 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -1761,25 +1746,25 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
struct ipx_opt *ipxs = ipx_sk(sk); struct ipx_opt *ipxs = ipx_sk(sk);
struct ipx_interface *intrfc; struct ipx_interface *intrfc;
struct sockaddr_ipx *addr = (struct sockaddr_ipx *)uaddr; struct sockaddr_ipx *addr = (struct sockaddr_ipx *)uaddr;
int ret = -EINVAL; int rc = -EINVAL;
if (!sk->zapped || addr_len != sizeof(struct sockaddr_ipx)) if (!sk->zapped || addr_len != sizeof(struct sockaddr_ipx))
goto out; goto out;
intrfc = ipxitf_find_using_net(addr->sipx_network); intrfc = ipxitf_find_using_net(addr->sipx_network);
ret = -EADDRNOTAVAIL; rc = -EADDRNOTAVAIL;
if (!intrfc) if (!intrfc)
goto out; goto out;
if (!addr->sipx_port) { if (!addr->sipx_port) {
addr->sipx_port = ipx_first_free_socketnum(intrfc); addr->sipx_port = ipx_first_free_socketnum(intrfc);
ret = -EINVAL; rc = -EINVAL;
if (!addr->sipx_port) if (!addr->sipx_port)
goto out_put; goto out_put;
} }
/* protect IPX system stuff like routing/sap */ /* protect IPX system stuff like routing/sap */
ret = -EACCES; rc = -EACCES;
if (ntohs(addr->sipx_port) < IPX_MIN_EPHEMERAL_SOCKET && if (ntohs(addr->sipx_port) < IPX_MIN_EPHEMERAL_SOCKET &&
!capable(CAP_NET_ADMIN)) !capable(CAP_NET_ADMIN))
goto out_put; goto out_put;
...@@ -1793,7 +1778,7 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -1793,7 +1778,7 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
* node number 0 was specified, the default is used. * node number 0 was specified, the default is used.
*/ */
ret = -EINVAL; rc = -EINVAL;
if (!memcmp(addr->sipx_node, ipx_broadcast_node, IPX_NODE_LEN)) if (!memcmp(addr->sipx_node, ipx_broadcast_node, IPX_NODE_LEN))
goto out_put; goto out_put;
if (!memcmp(addr->sipx_node, ipx_this_node, IPX_NODE_LEN)) if (!memcmp(addr->sipx_node, ipx_this_node, IPX_NODE_LEN))
...@@ -1801,7 +1786,7 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -1801,7 +1786,7 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
else else
memcpy(ipxs->node, addr->sipx_node, IPX_NODE_LEN); memcpy(ipxs->node, addr->sipx_node, IPX_NODE_LEN);
ret = -EADDRINUSE; rc = -EADDRINUSE;
if (ipxitf_find_internal_socket(intrfc, ipxs->node, if (ipxitf_find_internal_socket(intrfc, ipxs->node,
ipxs->port)) { ipxs->port)) {
SOCK_DEBUG(sk, SOCK_DEBUG(sk,
...@@ -1817,7 +1802,7 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -1817,7 +1802,7 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
memcpy(ipxs->node, intrfc->if_node, IPX_NODE_LEN); memcpy(ipxs->node, intrfc->if_node, IPX_NODE_LEN);
ret = -EADDRINUSE; rc = -EADDRINUSE;
if (ipxitf_find_socket(intrfc, addr->sipx_port)) { if (ipxitf_find_socket(intrfc, addr->sipx_port)) {
SOCK_DEBUG(sk, SOCK_DEBUG(sk,
"IPX: bind failed because port %X in use.\n", "IPX: bind failed because port %X in use.\n",
...@@ -1831,7 +1816,7 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -1831,7 +1816,7 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
/* Source addresses are easy. It must be our network:node pair for /* Source addresses are easy. It must be our network:node pair for
an interface routed to IPX with the ipx routing ioctl() */ an interface routed to IPX with the ipx routing ioctl() */
ret = -EADDRINUSE; rc = -EADDRINUSE;
if (ipxitf_find_socket(intrfc, addr->sipx_port)) { if (ipxitf_find_socket(intrfc, addr->sipx_port)) {
SOCK_DEBUG(sk, "IPX: bind failed because port %X in use.\n", SOCK_DEBUG(sk, "IPX: bind failed because port %X in use.\n",
ntohs((int)addr->sipx_port)); ntohs((int)addr->sipx_port));
...@@ -1844,11 +1829,11 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -1844,11 +1829,11 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
sk->zapped = 0; sk->zapped = 0;
SOCK_DEBUG(sk, "IPX: bound socket 0x%04X.\n", ntohs(addr->sipx_port) ); SOCK_DEBUG(sk, "IPX: bound socket 0x%04X.\n", ntohs(addr->sipx_port) );
ret = 0; rc = 0;
out_put: out_put:
ipxitf_put(intrfc); ipxitf_put(intrfc);
out: out:
return ret; return rc;
} }
static int ipx_connect(struct socket *sock, struct sockaddr *uaddr, static int ipx_connect(struct socket *sock, struct sockaddr *uaddr,
...@@ -1857,7 +1842,7 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -1857,7 +1842,7 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr,
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct ipx_opt *ipxs = ipx_sk(sk); struct ipx_opt *ipxs = ipx_sk(sk);
struct sockaddr_ipx *addr; struct sockaddr_ipx *addr;
int ret = -EINVAL; int rc = -EINVAL;
struct ipx_route *rt; struct ipx_route *rt;
sk->state = TCP_CLOSE; sk->state = TCP_CLOSE;
...@@ -1875,23 +1860,23 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -1875,23 +1860,23 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr,
uaddr.sipx_network = 0; uaddr.sipx_network = 0;
#ifdef CONFIG_IPX_INTERN #ifdef CONFIG_IPX_INTERN
ret = -ENETDOWN; rc = -ENETDOWN;
if (!ipxs->intrfc) if (!ipxs->intrfc)
goto out; /* Someone zonked the iface */ goto out; /* Someone zonked the iface */
memcpy(uaddr.sipx_node, ipxs->intrfc->if_node, memcpy(uaddr.sipx_node, ipxs->intrfc->if_node,
IPX_NODE_LEN); IPX_NODE_LEN);
#endif /* CONFIG_IPX_INTERN */ #endif /* CONFIG_IPX_INTERN */
ret = ipx_bind(sock, (struct sockaddr *)&uaddr, rc = ipx_bind(sock, (struct sockaddr *)&uaddr,
sizeof(struct sockaddr_ipx)); sizeof(struct sockaddr_ipx));
if (ret) if (rc)
goto out; goto out;
} }
/* We can either connect to primary network or somewhere /* We can either connect to primary network or somewhere
* we can route to */ * we can route to */
rt = ipxrtr_lookup(addr->sipx_network); rt = ipxrtr_lookup(addr->sipx_network);
ret = -ENETUNREACH; rc = -ENETUNREACH;
if (!rt && !(!addr->sipx_network && ipx_primary_net)) if (!rt && !(!addr->sipx_network && ipx_primary_net))
goto out; goto out;
...@@ -1907,9 +1892,9 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -1907,9 +1892,9 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr,
if (rt) if (rt)
ipxrtr_put(rt); ipxrtr_put(rt);
ret = 0; rc = 0;
out: out:
return ret; return rc;
} }
...@@ -1920,12 +1905,12 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -1920,12 +1905,12 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr,
struct sockaddr_ipx sipx; struct sockaddr_ipx sipx;
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct ipx_opt *ipxs = ipx_sk(sk); struct ipx_opt *ipxs = ipx_sk(sk);
int ret; int rc;
*uaddr_len = sizeof(struct sockaddr_ipx); *uaddr_len = sizeof(struct sockaddr_ipx);
if (peer) { if (peer) {
ret = -ENOTCONN; rc = -ENOTCONN;
if (sk->state != TCP_ESTABLISHED) if (sk->state != TCP_ESTABLISHED)
goto out; goto out;
...@@ -1955,9 +1940,9 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -1955,9 +1940,9 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr,
sipx.sipx_type = ipxs->type; sipx.sipx_type = ipxs->type;
memcpy(uaddr, &sipx, sizeof(sipx)); memcpy(uaddr, &sipx, sizeof(sipx));
ret = 0; rc = 0;
out: out:
return ret; return rc;
} }
int ipx_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) int ipx_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt)
...@@ -1966,7 +1951,7 @@ int ipx_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) ...@@ -1966,7 +1951,7 @@ int ipx_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt)
struct ipx_interface *intrfc; struct ipx_interface *intrfc;
struct ipxhdr *ipx; struct ipxhdr *ipx;
u16 ipx_pktsize; u16 ipx_pktsize;
int ret = 0; int rc = 0;
/* Not ours */ /* Not ours */
if (skb->pkt_type == PACKET_OTHERHOST) if (skb->pkt_type == PACKET_OTHERHOST)
...@@ -2005,13 +1990,13 @@ int ipx_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) ...@@ -2005,13 +1990,13 @@ int ipx_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt)
goto drop; goto drop;
} }
ret = ipxitf_rcv(intrfc, skb); rc = ipxitf_rcv(intrfc, skb);
ipxitf_put(intrfc); ipxitf_put(intrfc);
goto out; goto out;
drop: drop:
kfree_skb(skb); kfree_skb(skb);
out: out:
return ret; return rc;
} }
static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock, static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock,
...@@ -2021,7 +2006,7 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -2021,7 +2006,7 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock,
struct ipx_opt *ipxs = ipx_sk(sk); struct ipx_opt *ipxs = ipx_sk(sk);
struct sockaddr_ipx *usipx = (struct sockaddr_ipx *)msg->msg_name; struct sockaddr_ipx *usipx = (struct sockaddr_ipx *)msg->msg_name;
struct sockaddr_ipx local_sipx; struct sockaddr_ipx local_sipx;
int ret = -EINVAL; int rc = -EINVAL;
int flags = msg->msg_flags; int flags = msg->msg_flags;
/* Socket gets bound below anyway */ /* Socket gets bound below anyway */
...@@ -2037,24 +2022,24 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -2037,24 +2022,24 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock,
uaddr.sipx_port = 0; uaddr.sipx_port = 0;
uaddr.sipx_network = 0; uaddr.sipx_network = 0;
#ifdef CONFIG_IPX_INTERN #ifdef CONFIG_IPX_INTERN
ret = -ENETDOWN; rc = -ENETDOWN;
if (!ipxs->intrfc) if (!ipxs->intrfc)
goto out; /* Someone zonked the iface */ goto out; /* Someone zonked the iface */
memcpy(uaddr.sipx_node, ipxs->intrfc->if_node, memcpy(uaddr.sipx_node, ipxs->intrfc->if_node,
IPX_NODE_LEN); IPX_NODE_LEN);
#endif #endif
ret = ipx_bind(sock, (struct sockaddr *)&uaddr, rc = ipx_bind(sock, (struct sockaddr *)&uaddr,
sizeof(struct sockaddr_ipx)); sizeof(struct sockaddr_ipx));
if (ret) if (rc)
goto out; goto out;
} }
ret = -EINVAL; rc = -EINVAL;
if (msg->msg_namelen < sizeof(*usipx) || if (msg->msg_namelen < sizeof(*usipx) ||
usipx->sipx_family != AF_IPX) usipx->sipx_family != AF_IPX)
goto out; goto out;
} else { } else {
ret = -ENOTCONN; rc = -ENOTCONN;
if (sk->state != TCP_ESTABLISHED) if (sk->state != TCP_ESTABLISHED)
goto out; goto out;
...@@ -2066,12 +2051,12 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -2066,12 +2051,12 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock,
memcpy(usipx->sipx_node, ipxs->dest_addr.node, IPX_NODE_LEN); memcpy(usipx->sipx_node, ipxs->dest_addr.node, IPX_NODE_LEN);
} }
ret = ipxrtr_route_packet(sk, usipx, msg->msg_iov, len, rc = ipxrtr_route_packet(sk, usipx, msg->msg_iov, len,
flags & MSG_DONTWAIT); flags & MSG_DONTWAIT);
if (ret >= 0) if (rc >= 0)
ret = len; rc = len;
out: out:
return ret; return rc;
} }
...@@ -2083,7 +2068,7 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -2083,7 +2068,7 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock,
struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)msg->msg_name; struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)msg->msg_name;
struct ipxhdr *ipx = NULL; struct ipxhdr *ipx = NULL;
struct sk_buff *skb; struct sk_buff *skb;
int copied, err; int copied, rc;
/* put the autobinding in */ /* put the autobinding in */
if (!ipxs->port) { if (!ipxs->port) {
...@@ -2093,24 +2078,24 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -2093,24 +2078,24 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock,
uaddr.sipx_network = 0; uaddr.sipx_network = 0;
#ifdef CONFIG_IPX_INTERN #ifdef CONFIG_IPX_INTERN
err = -ENETDOWN; rc = -ENETDOWN;
if (!ipxs->intrfc) if (!ipxs->intrfc)
goto out; /* Someone zonked the iface */ goto out; /* Someone zonked the iface */
memcpy(uaddr.sipx_node, ipxs->intrfc->if_node, IPX_NODE_LEN); memcpy(uaddr.sipx_node, ipxs->intrfc->if_node, IPX_NODE_LEN);
#endif /* CONFIG_IPX_INTERN */ #endif /* CONFIG_IPX_INTERN */
err = ipx_bind(sock, (struct sockaddr *)&uaddr, rc = ipx_bind(sock, (struct sockaddr *)&uaddr,
sizeof(struct sockaddr_ipx)); sizeof(struct sockaddr_ipx));
if (err) if (rc)
goto out; goto out;
} }
err = -ENOTCONN; rc = -ENOTCONN;
if (sk->zapped) if (sk->zapped)
goto out; goto out;
skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
flags & MSG_DONTWAIT, &err); flags & MSG_DONTWAIT, &rc);
if (!skb) if (!skb)
goto out; goto out;
...@@ -2121,9 +2106,9 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -2121,9 +2106,9 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock,
msg->msg_flags |= MSG_TRUNC; msg->msg_flags |= MSG_TRUNC;
} }
err = skb_copy_datagram_iovec(skb, sizeof(struct ipxhdr), msg->msg_iov, rc = skb_copy_datagram_iovec(skb, sizeof(struct ipxhdr), msg->msg_iov,
copied); copied);
if (err) if (rc)
goto out_free; goto out_free;
sk->stamp = skb->stamp; sk->stamp = skb->stamp;
...@@ -2136,17 +2121,18 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -2136,17 +2121,18 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock,
sipx->sipx_network = IPX_SKB_CB(skb)->ipx_source_net; sipx->sipx_network = IPX_SKB_CB(skb)->ipx_source_net;
sipx->sipx_type = ipx->ipx_type; sipx->sipx_type = ipx->ipx_type;
} }
err = copied; rc = copied;
out_free: out_free:
skb_free_datagram(sk, skb); skb_free_datagram(sk, skb);
out: out:
return err; return rc;
} }
static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
{ {
int rc = 0;
long amount = 0; long amount = 0;
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
...@@ -2155,73 +2141,72 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -2155,73 +2141,72 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
amount = sk->sndbuf - atomic_read(&sk->wmem_alloc); amount = sk->sndbuf - atomic_read(&sk->wmem_alloc);
if (amount < 0) if (amount < 0)
amount = 0; amount = 0;
return put_user(amount, (int *)arg); rc = put_user(amount, (int *)arg);
break;
case TIOCINQ: { case TIOCINQ: {
struct sk_buff *skb = skb_peek(&sk->receive_queue); struct sk_buff *skb = skb_peek(&sk->receive_queue);
/* These two are safe on a single CPU system as only /* These two are safe on a single CPU system as only
* user tasks fiddle here */ * user tasks fiddle here */
if (skb) if (skb)
amount = skb->len - sizeof(struct ipxhdr); amount = skb->len - sizeof(struct ipxhdr);
return put_user(amount, (int *)arg); rc = put_user(amount, (int *)arg);
break;
} }
case SIOCADDRT: case SIOCADDRT:
case SIOCDELRT: case SIOCDELRT:
if (!capable(CAP_NET_ADMIN)) rc = -EPERM;
return -EPERM; if (capable(CAP_NET_ADMIN))
return ipxrtr_ioctl(cmd, (void *)arg); rc = ipxrtr_ioctl(cmd, (void *)arg);
break;
case SIOCSIFADDR: case SIOCSIFADDR:
case SIOCAIPXITFCRT: case SIOCAIPXITFCRT:
case SIOCAIPXPRISLT: case SIOCAIPXPRISLT:
rc = -EPERM;
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EPERM; break;
case SIOCGIFADDR: case SIOCGIFADDR:
return ipxitf_ioctl(cmd, (void *)arg); rc = ipxitf_ioctl(cmd, (void *)arg);
break;
case SIOCIPXCFGDATA: case SIOCIPXCFGDATA:
return ipxcfg_get_config_data((void *)arg); rc = ipxcfg_get_config_data((void *)arg);
break;
case SIOCIPXNCPCONN: case SIOCIPXNCPCONN:
/* /*
* This socket wants to take care of the NCP connection * This socket wants to take care of the NCP connection
* handed to us in arg. * handed to us in arg.
*/ */
rc = -EPERM;
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EPERM; break;
return get_user(ipx_sk(sk)->ipx_ncp_conn, rc = get_user(ipx_sk(sk)->ipx_ncp_conn,
(const unsigned short *)(arg)); (const unsigned short *)(arg));
break;
case SIOCGSTAMP: { case SIOCGSTAMP:
int ret = -EINVAL; rc = -EINVAL;
if (sk) { if (sk) {
rc = -ENOENT;
if (!sk->stamp.tv_sec) if (!sk->stamp.tv_sec)
return -ENOENT; break;
ret = -EFAULT; rc = -EFAULT;
if (!copy_to_user((void *)arg, &sk->stamp, if (!copy_to_user((void *)arg, &sk->stamp,
sizeof(struct timeval))) sizeof(struct timeval)))
ret = 0; rc = 0;
}
return ret;
} }
break;
case SIOCGIFDSTADDR: case SIOCGIFDSTADDR:
case SIOCSIFDSTADDR: case SIOCSIFDSTADDR:
case SIOCGIFBRDADDR: case SIOCGIFBRDADDR:
case SIOCSIFBRDADDR: case SIOCSIFBRDADDR:
case SIOCGIFNETMASK: case SIOCGIFNETMASK:
case SIOCSIFNETMASK: case SIOCSIFNETMASK:
return -EINVAL; rc = -EINVAL;
break;
default: default:
return dev_ioctl(cmd,(void *) arg); rc = dev_ioctl(cmd,(void *) arg);
break;
} }
/*NOT REACHED*/ return rc;
return 0;
} }
/* /*
...@@ -2260,17 +2245,17 @@ SOCKOPS_WRAP(ipx_dgram, PF_IPX); ...@@ -2260,17 +2245,17 @@ SOCKOPS_WRAP(ipx_dgram, PF_IPX);
static struct packet_type ipx_8023_packet_type = { static struct packet_type ipx_8023_packet_type = {
.type = __constant_htons(ETH_P_802_3), .type = __constant_htons(ETH_P_802_3),
.func = ipx_rcv, .func = ipx_rcv,
.data = (void *) 1, /* yap, I understand shared skbs :-) */ .data = (void *)1, /* yap, I understand shared skbs :-) */
}; };
static struct packet_type ipx_dix_packet_type = { static struct packet_type ipx_dix_packet_type = {
.type = __constant_htons(ETH_P_IPX), .type = __constant_htons(ETH_P_IPX),
.func = ipx_rcv, .func = ipx_rcv,
.data = (void *) 1, /* yap, I understand shared skbs :-) */ .data = (void *)1, /* yap, I understand shared skbs :-) */
}; };
static struct notifier_block ipx_dev_notifier = { static struct notifier_block ipx_dev_notifier = {
.notifier_call =ipxitf_device_event, .notifier_call = ipxitf_device_event,
}; };
extern struct datalink_proto *make_EII_client(void); extern struct datalink_proto *make_EII_client(void);
...@@ -2324,21 +2309,6 @@ static int __init ipx_init(void) ...@@ -2324,21 +2309,6 @@ static int __init ipx_init(void)
return 0; return 0;
} }
module_init(ipx_init);
/* Note on MOD_{INC,DEC}_USE_COUNT:
*
* Use counts are incremented/decremented when
* sockets are created/deleted.
*
* Routes are always associated with an interface, and
* allocs/frees will remain properly accounted for by
* their associated interfaces.
*
* Ergo, before the ipx module can be removed, all IPX
* sockets be closed from user space.
*/
static void __exit ipx_proto_finito(void) static void __exit ipx_proto_finito(void)
{ {
/* /*
...@@ -2369,5 +2339,6 @@ static void __exit ipx_proto_finito(void) ...@@ -2369,5 +2339,6 @@ static void __exit ipx_proto_finito(void)
sock_unregister(ipx_family_ops.family); sock_unregister(ipx_family_ops.family);
} }
module_init(ipx_init);
module_exit(ipx_proto_finito); module_exit(ipx_proto_finito);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
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