summaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-04-28 01:09:25 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-04-28 01:09:25 +0000
commitb9ba7aeb165cffecdffb60aec8c3fa8d590d9ca9 (patch)
tree42d07b0c7246ae2536a702e7c5de9e2732341116 /net/core
parent7406b0a326f2d70ade2671c37d1beef62249db97 (diff)
Merge with 2.3.99-pre6.
Diffstat (limited to 'net/core')
-rw-r--r--net/core/dev.c72
-rw-r--r--net/core/neighbour.c8
-rw-r--r--net/core/netfilter.c14
-rw-r--r--net/core/skbuff.c34
-rw-r--r--net/core/sock.c28
5 files changed, 79 insertions, 77 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 81a35e7a0..cb6b75d9f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -181,7 +181,7 @@ int netdev_nit=0;
* dev_add_pack - add packet handler
* @pt: packet type declaration
*
- * Add a protocol handler to the networking stack. The passed packet_type
+ * Add a protocol handler to the networking stack. The passed &packet_type
* is linked into kernel lists and may not be freed until it has been
* removed from the kernel lists.
*/
@@ -217,7 +217,7 @@ void dev_add_pack(struct packet_type *pt)
* @pt: packet type declaration
*
* Remove a protocol handler that was previously added to the kernel
- * protocol handlers by dev_add_pack. The passed packet_type is removed
+ * protocol handlers by dev_add_pack(). The passed &packet_type is removed
* from the kernel lists and can be freed or reused once this function
* returns.
*/
@@ -260,9 +260,9 @@ void dev_remove_pack(struct packet_type *pt)
* __dev_get_by_name - find a device by its name
* @name: name to find
*
- * Find an interface by name. Must be called under rtnl semaphore
- * or dev_base_lock. If the name is found a pointer to the device
- * is returned. If the name is not found then NULL is returned. The
+ * Find an interface by name. Must be called under RTNL semaphore
+ * or @dev_base_lock. If the name is found a pointer to the device
+ * is returned. If the name is not found then %NULL is returned. The
* reference counters are not incremented so the caller must be
* careful with locks.
*/
@@ -286,7 +286,7 @@ struct net_device *__dev_get_by_name(const char *name)
* Find an interface by name. This can be called from any
* context and does its own locking. The returned handle has
* the usage count incremented and the caller must use dev_put() to
- * release it when it is no longer needed. NULL is returned if no
+ * release it when it is no longer needed. %NULL is returned if no
* matching device is found.
*/
@@ -336,11 +336,11 @@ int dev_get(const char *name)
* __dev_get_by_index - find a device by its ifindex
* @ifindex: index of device
*
- * Search for an interface by index. Returns NULL if the device
+ * Search for an interface by index. Returns %NULL if the device
* is not found or a pointer to the device. The device has not
* had its reference counter increased so the caller must be careful
- * about locking. The caller must hold either the rtnl semaphore
- * or dev_base_lock.
+ * about locking. The caller must hold either the RTNL semaphore
+ * or @dev_base_lock.
*/
struct net_device * __dev_get_by_index(int ifindex)
@@ -440,15 +440,15 @@ int dev_alloc_name(struct net_device *dev, const char *name)
* @name: name format string
* @err: error return pointer
*
- * Passed a format string - eg "lt%d" it will allocate a network device
- * and space for the name. NULL is returned if no memory is available.
+ * Passed a format string, eg. "lt%d", it will allocate a network device
+ * and space for the name. %NULL is returned if no memory is available.
* If the allocation succeeds then the name is assigned and the
- * device pointer returned. NULL is returned if the name allocation failed.
- * The cause of an error is returned as a negative errno code in the
- * variable err points to.
+ * device pointer returned. %NULL is returned if the name allocation
+ * failed. The cause of an error is returned as a negative errno code
+ * in the variable @err points to.
*
- * The claler must hold the dev_base or rtnl locks when doing this in order
- * to avoid duplicate name allocations.
+ * The caller must hold the @dev_base or RTNL locks when doing this in
+ * order to avoid duplicate name allocations.
*/
struct net_device *dev_alloc(const char *name, int *err)
@@ -520,9 +520,9 @@ static int default_rebuild_header(struct sk_buff *skb)
* dev_open - prepare an interface for use.
* @dev: device to open
*
- * Takes a device from down to up state. The devices private open
+ * Takes a device from down to up state. The device's private open
* function is invoked and then the multicast lists are loaded. Finally
- * the device is moved into the up state and a NETDEV_UP message is
+ * the device is moved into the up state and a %NETDEV_UP message is
* sent to the netdev notifier chain.
*
* Calling this function on an active interface is a nop. On a failure
@@ -622,8 +622,8 @@ void dev_clear_fastroute(struct net_device *dev)
* @dev: device to shutdown
*
* This function moves an active device into down state. A
- * NETDEV_GOING_DOWN is sent to the netev notifier chain. The device
- * is then deactivated and finally a NETDEV_DOWN is sent to the notifier
+ * %NETDEV_GOING_DOWN is sent to the netdev notifier chain. The device
+ * is then deactivated and finally a %NETDEV_DOWN is sent to the notifier
* chain.
*/
@@ -695,9 +695,10 @@ int register_netdevice_notifier(struct notifier_block *nb)
* unregister_netdevice_notifier - unregister a network notifier block
* @nb: notifier
*
- * Unregister a notifier previously registered by register_netdevice_notifier
- * The notifier is unlinked into the kernel structures and may
- * then be reused. A negative errno code is returned on a failure.
+ * Unregister a notifier previously registered by
+ * register_netdevice_notifier(). The notifier is unlinked into the
+ * kernel structures and may then be reused. A negative errno code
+ * is returned on a failure.
*/
int unregister_netdevice_notifier(struct notifier_block *nb)
@@ -1079,7 +1080,7 @@ static void net_tx_action(struct softirq_action *h)
* @fn: function to call
*
* Make a function call that is atomic with respect to the protocol
- * layers
+ * layers.
*/
void net_call_rx_atomic(void (*fn)(void))
@@ -1426,10 +1427,11 @@ static int dev_get_info(char *buffer, char **start, off_t offset, int length)
static int dev_proc_stats(char *buffer, char **start, off_t offset,
int length, int *eof, void *data)
{
- int i;
+ int i, lcpu;
int len=0;
- for (i=0; i<smp_num_cpus; i++) {
+ for (lcpu=0; lcpu<smp_num_cpus; lcpu++) {
+ i = cpu_logical_map(lcpu);
len += sprintf(buffer+len, "%08x %08x %08x %08x %08x %08x %08x %08x %08x\n",
netdev_rx_stat[i].total,
netdev_rx_stat[i].dropped,
@@ -1554,10 +1556,10 @@ static int dev_get_wireless_info(char * buffer, char **start, off_t offset,
* @slave: slave device
* @master: new master device
*
- * Changes the master device of the slave. Pass NULL to break the
+ * Changes the master device of the slave. Pass %NULL to break the
* bonding. The caller must hold the RTNL semaphore. On a failure
* a negative errno code is returned. On success the reference counts
- * are adjusted, RTM_NEWLINK is sent to the routing socket and the
+ * are adjusted, %RTM_NEWLINK is sent to the routing socket and the
* function returns zero.
*/
@@ -1629,7 +1631,7 @@ void dev_set_promiscuity(struct net_device *dev, int inc)
* Add or remove reception of all multicast frames to a device. While the
* count in the device remains above zero the interface remains listening
* to all interfaces. Once it hits zero the device reverts back to normal
- * filtering operation. A negative inc value is used to drop the counter
+ * filtering operation. A negative @inc value is used to drop the counter
* when releasing a resource needing all multicasts.
*/
@@ -2005,12 +2007,16 @@ int dev_ioctl(unsigned int cmd, void *arg)
return ret;
}
#ifdef WIRELESS_EXT
+ /* Take care of Wireless Extensions */
if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) {
- dev_load(ifr.ifr_name);
- if (IW_IS_SET(cmd)) {
- if (!suser())
+ /* If command is `set a parameter', or
+ * `get the encoding parameters', check if
+ * the user has the right to do it */
+ if (IW_IS_SET(cmd) || (cmd == SIOCGIWENCODE)) {
+ if(!capable(CAP_NET_ADMIN))
return -EPERM;
}
+ dev_load(ifr.ifr_name);
rtnl_lock();
ret = dev_ifsioc(&ifr, cmd);
rtnl_unlock();
@@ -2051,7 +2057,7 @@ static int dev_boot_phase = 1;
* @dev: device to register
*
* Take a completed network device structure and add it to the kernel
- * interfaces. A NETDEV_REGISTER message is sent to the netdev notifier
+ * interfaces. A %NETDEV_REGISTER message is sent to the netdev notifier
* chain. 0 is returned on success. A negative errno code is returned
* on a failure to set up the device, or if the name is a duplicate.
*
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index d97bdc5f2..5a3ccd062 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -54,7 +54,7 @@ static int pneigh_ifdown(struct neigh_table *tbl, struct net_device *dev);
static int neigh_glbl_allocs;
static struct neigh_table *neigh_tables;
-#if defined(__i386__) && defined(__SMP__)
+#if defined(__i386__) && defined(CONFIG_SMP)
#define ASSERT_WL(n) if ((int)((n)->lock.lock) > 0) { printk("WL assertion failed at " __FILE__ "(%d):" __FUNCTION__ "\n", __LINE__); }
#else
#define ASSERT_WL(n) do { } while(0)
@@ -597,7 +597,7 @@ next_elt:
write_unlock(&tbl->lock);
}
-#ifdef __SMP__
+#ifdef CONFIG_SMP
static void neigh_periodic_timer(unsigned long arg)
{
struct neigh_table *tbl = (struct neigh_table*)arg;
@@ -629,7 +629,7 @@ static void neigh_timer_handler(unsigned long arg)
state = neigh->nud_state;
if (!(state&NUD_IN_TIMER)) {
-#ifndef __SMP__
+#ifndef CONFIG_SMP
printk("neigh: timer & !nud_in_timer\n");
#endif
goto out;
@@ -1106,7 +1106,7 @@ void neigh_table_init(struct neigh_table *tbl)
0, SLAB_HWCACHE_ALIGN,
NULL, NULL);
-#ifdef __SMP__
+#ifdef CONFIG_SMP
tasklet_init(&tbl->gc_task, SMP_TIMER_NAME(neigh_periodic_timer), (unsigned long)tbl);
#endif
init_timer(&tbl->gc_timer);
diff --git a/net/core/netfilter.c b/net/core/netfilter.c
index 02c3bc989..7f9b9e82b 100644
--- a/net/core/netfilter.c
+++ b/net/core/netfilter.c
@@ -186,18 +186,10 @@ void nf_dump_skb(int pf, struct sk_buff *skb)
dst_port = ntohs(tcp->dest);
}
- printk("PROTO=%d %d.%d.%d.%d:%hu %d.%d.%d.%d:%hu"
+ printk("PROTO=%d %u.%u.%u.%u:%hu %u.%u.%u.%u:%hu"
" L=%hu S=0x%2.2hX I=%hu F=0x%4.4hX T=%hu",
- ip->protocol,
- (ntohl(ip->saddr)>>24)&0xFF,
- (ntohl(ip->saddr)>>16)&0xFF,
- (ntohl(ip->saddr)>>8)&0xFF,
- (ntohl(ip->saddr))&0xFF,
- src_port,
- (ntohl(ip->daddr)>>24)&0xFF,
- (ntohl(ip->daddr)>>16)&0xFF,
- (ntohl(ip->daddr)>>8)&0xFF,
- (ntohl(ip->daddr))&0xFF,
+ ip->protocol, NIPQUAD(ip->saddr),
+ src_port, NIPQUAD(ip->daddr),
dst_port,
ntohs(ip->tot_len), ip->tos, ntohs(ip->id),
ntohs(ip->frag_off), ip->ttl);
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 54230a273..234e9c182 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4,7 +4,7 @@
* Authors: Alan Cox <iiitac@pyr.swan.ac.uk>
* Florian La Roche <rzsfl@rz.uni-sb.de>
*
- * Version: $Id: skbuff.c,v 1.71 2000/03/29 11:58:33 davem Exp $
+ * Version: $Id: skbuff.c,v 1.72 2000/04/13 00:55:54 davem Exp $
*
* Fixes:
* Alan Cox : Fixed the worst of the load balancer bugs.
@@ -83,7 +83,7 @@ static union {
* @sz: size
* @here: address
*
- * Out of line support code for skb_put. Not user callable
+ * Out of line support code for skb_put(). Not user callable.
*/
void skb_over_panic(struct sk_buff *skb, int sz, void *here)
@@ -99,7 +99,7 @@ void skb_over_panic(struct sk_buff *skb, int sz, void *here)
* @sz: size
* @here: address
*
- * Out of line support code for skb_push. Not user callable
+ * Out of line support code for skb_push(). Not user callable.
*/
@@ -154,12 +154,12 @@ static __inline__ void skb_head_to_pool(struct sk_buff *skb)
* @size: size to allocate
* @gfp_mask: allocation mask
*
- * Allocate a new sk_buff. The returned buffer has no headroom and a
+ * Allocate a new &sk_buff. The returned buffer has no headroom and a
* tail room of size bytes. The object has a reference count of one.
- * The return is the buffer. On a failure the return is NULL.
+ * The return is the buffer. On a failure the return is %NULL.
*
- * Buffers may only be allocated from interrupts using a gfp_mask of
- * GFP_ATOMIC.
+ * Buffers may only be allocated from interrupts using a @gfp_mask of
+ * %GFP_ATOMIC.
*/
struct sk_buff *alloc_skb(unsigned int size,int gfp_mask)
@@ -300,13 +300,13 @@ void __kfree_skb(struct sk_buff *skb)
* @skb: buffer to clone
* @gfp_mask: allocation priority
*
- * Duplicate an sk_buff. The new one is not owned by a socket. Both
+ * Duplicate an &sk_buff. The new one is not owned by a socket. Both
* copies share the same packet data but not structure. The new
* buffer has a reference count of 1. If the allocation fails the
- * function returns NULL otherwise the new buffer is returned.
+ * function returns %NULL otherwise the new buffer is returned.
*
- * If this function is called from an interrupt gfp_mask must be
- * GFP_ATOMIC.
+ * If this function is called from an interrupt gfp_mask() must be
+ * %GFP_ATOMIC.
*/
struct sk_buff *skb_clone(struct sk_buff *skb, int gfp_mask)
@@ -383,12 +383,12 @@ static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
* @skb: buffer to copy
* @gfp_mask: allocation priority
*
- * Make a copy of both an sk_buff and its data. This is used when the
+ * Make a copy of both an &sk_buff and its data. This is used when the
* caller wishes to modify the data and needs a private copy of the
- * data to alter. Returns NULL on failure or the pointer to the buffer
+ * data to alter. Returns %NULL on failure or the pointer to the buffer
* on success. The returned buffer has a reference count of 1.
*
- * You must pass GFP_ATOMIC as the allocation priority if this function
+ * You must pass %GFP_ATOMIC as the allocation priority if this function
* is called from an interrupt.
*/
@@ -423,15 +423,15 @@ struct sk_buff *skb_copy(const struct sk_buff *skb, int gfp_mask)
* @newtailroom: new free bytes at tail
* @gfp_mask: allocation priority
*
- * Make a copy of both an sk_buff and its data and while doing so
+ * Make a copy of both an &sk_buff and its data and while doing so
* allocate additional space.
*
* This is used when the caller wishes to modify the data and needs a
* private copy of the data to alter as well as more space for new fields.
- * Returns NULL on failure or the pointer to the buffer
+ * Returns %NULL on failure or the pointer to the buffer
* on success. The returned buffer has a reference count of 1.
*
- * You must pass GFP_ATOMIC as the allocation priority if this function
+ * You must pass %GFP_ATOMIC as the allocation priority if this function
* is called from an interrupt.
*/
diff --git a/net/core/sock.c b/net/core/sock.c
index ce25381c9..4044a7f7d 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -7,7 +7,7 @@
* handler for protocols to use and generic option handler.
*
*
- * Version: $Id: sock.c,v 1.91 2000/03/25 01:55:03 davem Exp $
+ * Version: $Id: sock.c,v 1.93 2000/04/13 03:13:29 davem Exp $
*
* Authors: Ross Biro, <bir7@leland.Stanford.Edu>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
@@ -786,18 +786,22 @@ struct sk_buff *sock_alloc_send_skb(struct sock *sk, unsigned long size,
if (sk->shutdown&SEND_SHUTDOWN)
goto failure;
- if (fallback) {
- /* The buffer get won't block, or use the atomic queue.
- * It does produce annoying no free page messages still.
- */
- skb = sock_wmalloc(sk, size, 0, GFP_BUFFER);
+ if (atomic_read(&sk->wmem_alloc) < sk->sndbuf) {
+ if (fallback) {
+ /* The buffer get won't block, or use the atomic queue.
+ * It does produce annoying no free page messages still.
+ */
+ skb = alloc_skb(size, GFP_BUFFER);
+ if (skb)
+ break;
+ try_size = fallback;
+ }
+ skb = alloc_skb(try_size, sk->allocation);
if (skb)
break;
- try_size = fallback;
+ err = -ENOBUFS;
+ goto failure;
}
- skb = sock_wmalloc(sk, try_size, 0, sk->allocation);
- if (skb)
- break;
/*
* This means we have too many buffers for this socket already.
@@ -813,6 +817,7 @@ struct sk_buff *sock_alloc_send_skb(struct sock *sk, unsigned long size,
timeo = sock_wait_for_wmem(sk, timeo);
}
+ skb_set_owner_w(skb, sk);
return skb;
interrupted:
@@ -1063,7 +1068,7 @@ int sock_no_sendmsg(struct socket *sock, struct msghdr *m, int flags,
return -EOPNOTSUPP;
}
-int sock_no_recvmsg(struct socket *sock, struct msghdr *m, int flags,
+int sock_no_recvmsg(struct socket *sock, struct msghdr *m, int len, int flags,
struct scm_cookie *scm)
{
return -EOPNOTSUPP;
@@ -1136,7 +1141,6 @@ void sock_init_data(struct socket *sock, struct sock *sk)
skb_queue_head_init(&sk->write_queue);
skb_queue_head_init(&sk->error_queue);
- spin_lock_init(&sk->timer_lock);
init_timer(&sk->timer);
sk->allocation = GFP_KERNEL;