Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Linux Kernel Patch v2.4, patch-2.4.10 (195/197)

5 views
Skip to first unread message

Thomas Kobienia

unread,
Sep 24, 2001, 8:00:58 PM9/24/01
to
Archive-name: v2.4/patch-2.4.10/part195

#!/bin/sh -x
# this is part 195 of a 197 - part archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file patch-2.4.10 continued
if test ! -r _shar_seq_.tmp; then
echo 'Please unpack part 1 first!'
exit 1
fi
(read Scheck
if test "$Scheck" != 195; then
echo "Please unpack part $Scheck next!"
exit 1
else
exit 0
fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
echo 'x - still skipping patch-2.4.10'
else
echo 'x - continuing with patch-2.4.10'
sed 's/^X//' << 'SHAR_EOF' >> 'patch-2.4.10' &&
+
+ if (sock_writeable(sk))
+ mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
+ else
+ set_bit(SOCK_ASYNC_NOSPACE, &sk->socket->flags);
+
+ return mask;
X }
X
X static int l2cap_sock_release(struct socket *sock)
@@ -1013,7 +1103,7 @@
X return s;
X }
X
-static __inline__ struct sock *l2cap_get_chan_by_dcid(struct l2cap_chan_list *l, __u16 cid)
+static inline struct sock *l2cap_get_chan_by_dcid(struct l2cap_chan_list *l, __u16 cid)
X {
X struct sock *s;
X
@@ -1035,7 +1125,7 @@
X
X return s;
X }
-static __inline__ struct sock *l2cap_get_chan_by_scid(struct l2cap_chan_list *l, __u16 cid)
+static inline struct sock *l2cap_get_chan_by_scid(struct l2cap_chan_list *l, __u16 cid)
X {
X struct sock *s;
X
@@ -1058,7 +1148,7 @@
X return s;
X }
X
-static __inline__ struct sock *l2cap_get_chan_by_ident(struct l2cap_chan_list *l, __u8 ident)
+static inline struct sock *l2cap_get_chan_by_ident(struct l2cap_chan_list *l, __u8 ident)
X {
X struct sock *s;
X
@@ -1081,7 +1171,7 @@
X return 0;
X }
X
-static __inline__ void __l2cap_chan_link(struct l2cap_chan_list *l, struct sock *sk)
+static inline void __l2cap_chan_link(struct l2cap_chan_list *l, struct sock *sk)
X {
X sock_hold(sk);
X
@@ -1093,7 +1183,7 @@
X l->head = sk;
X }
X
-static __inline__ void l2cap_chan_unlink(struct l2cap_chan_list *l, struct sock *sk)
+static inline void l2cap_chan_unlink(struct l2cap_chan_list *l, struct sock *sk)
X {
X struct sock *next = l2cap_pi(sk)->next_c, *prev = l2cap_pi(sk)->prev_c;
X
@@ -1116,6 +1206,8 @@
X
X DBG("conn %p, psm 0x%2.2x, dcid 0x%4.4x", conn, l2cap_pi(sk)->psm, l2cap_pi(sk)->dcid);
X
+ l2cap_conn_clear_timer(conn);
+
X atomic_inc(&conn->refcnt);
X l2cap_pi(sk)->conn = conn;
X
@@ -1135,7 +1227,7 @@
X l2cap_accept_queue(parent, sk);
X }
X
-static __inline__ void l2cap_chan_add(struct l2cap_conn *conn, struct sock *sk, struct sock *parent)
+static inline void l2cap_chan_add(struct l2cap_conn *conn, struct sock *sk, struct sock *parent)
X {
X struct l2cap_chan_list *l = &conn->chan_list;
X
@@ -1144,7 +1236,8 @@
X write_unlock(&l->lock);
X }
X
-/* Delete channel. Must be called on the locked socket. */
+/* Delete channel.
+ * Must be called on the locked socket. */
X static void l2cap_chan_del(struct sock *sk, int err)
X {
X struct l2cap_conn *conn;
@@ -1162,16 +1255,21 @@
X bh_unlock_sock(parent);
X }
X
- if (conn) {
+ if (conn) {
+ long timeout;
+
X /* Unlink from channel list */
X l2cap_chan_unlink(&conn->chan_list, sk);
X l2cap_pi(sk)->conn = NULL;
X
- if (conn->out &&
- conn->state == BT_CONNECTED &&
- atomic_dec_and_test(&conn->refcnt)) {
- /* Disconnect baseband */
- hci_disconnect(conn->hconn, 0x13);
+ if (conn->out)
+ timeout = L2CAP_DISCONN_TIMEOUT;
+ else
+ timeout = L2CAP_CONN_IDLE_TIMEOUT;
+
+ if (atomic_dec_and_test(&conn->refcnt) && conn->state == BT_CONNECTED) {
+ /* Schedule Baseband disconnect */
+ l2cap_conn_set_timer(conn, timeout);
X }
X }
X
@@ -1197,14 +1295,14 @@
X if (sk->type != SOCK_SEQPACKET) {
X sk->state = BT_CONNECTED;
X sk->state_change(sk);
- l2cap_clear_timer(sk);
+ l2cap_sock_clear_timer(sk);
X } else if (sk->state == BT_CONNECT) {
X l2cap_conn_req req;
X req.scid = __cpu_to_le16(l2cap_pi(sk)->scid);
X req.psm = l2cap_pi(sk)->psm;
X l2cap_send_req(conn, L2CAP_CONN_REQ, L2CAP_CONN_REQ_SIZE, &req);
X
- l2cap_set_timer(sk, sk->sndtimeo);
+ l2cap_sock_set_timer(sk, sk->sndtimeo);
X }
X
X bh_unlock_sock(sk);
@@ -1220,7 +1318,7 @@
X DBG("sk %p, parent %p", sk, parent);
X
X l2cap_pi(sk)->conf_state = 0;
- l2cap_clear_timer(sk);
+ l2cap_sock_clear_timer(sk);
X
X if (!parent) {
X /* Outgoing channel.
@@ -1232,7 +1330,7 @@
X /* Incomming channel.
X * Wake up socket sleeping on accept.
X */
- parent->state_change(parent);
+ parent->data_ready(parent, 1);
X }
X }
X
@@ -1254,7 +1352,7 @@
X if (skb->sk == sk)
X continue;
X
- if (!(nskb = bluez_skb_clone(skb, GFP_ATOMIC)))
+ if (!(nskb = skb_clone(skb, GFP_ATOMIC)))
X continue;
X
X skb_queue_tail(&sk->receive_queue, nskb);
@@ -1266,17 +1364,18 @@
X static int l2cap_chan_send(struct sock *sk, struct msghdr *msg, int len)
X {
X struct l2cap_conn *conn = l2cap_pi(sk)->conn;
- struct l2cap_iff *iff = conn->iff;
- struct sk_buff *skb, *frag;
+ struct sk_buff *skb, **frag;
X int err, size, count, sent=0;
- l2cap_hdr * lh;
+ l2cap_hdr *lh;
X
X /* Check outgoing MTU */
X if (len > l2cap_pi(sk)->omtu)
X return -EINVAL;
X
+ DBG("sk %p len %d", sk, len);
+
X /* First fragment (with L2CAP header) */
- count = MIN(iff->mtu - L2CAP_HDR_SIZE, len);
+ count = MIN(conn->iff->mtu - L2CAP_HDR_SIZE, len);
X size = L2CAP_HDR_SIZE + count;
X if (!(skb = bluez_skb_send_alloc(sk, size, msg->msg_flags & MSG_DONTWAIT, &err)))
X return err;
@@ -1295,21 +1394,23 @@
X len -= count;
X
X /* Continuation fragments (no L2CAP header) */
+ frag = &skb_shinfo(skb)->frag_list;
X while (len) {
- count = MIN(iff->mtu, len);
+ count = MIN(conn->iff->mtu, len);
X
- if (!(frag = bluez_skb_send_alloc(sk, count, msg->msg_flags & MSG_DONTWAIT, &err)))
+ *frag = bluez_skb_send_alloc(sk, count, msg->msg_flags & MSG_DONTWAIT, &err);
+ if (!*frag)
X goto fail;
-
- bluez_skb_add_frag(skb, frag);
-
- if (memcpy_fromiovec(skb_put(frag, count), msg->msg_iov, count)) {
+
+ if (memcpy_fromiovec(skb_put(*frag, count), msg->msg_iov, count)) {
X err = -EFAULT;
X goto fail;
X }
X
X sent += count;
X len -= count;
+
+ frag = &(*frag)->next;
X }
X
X if ((err = hci_send_acl(conn->hconn, skb, 0)) < 0)
@@ -1318,12 +1419,12 @@
X return sent;
X
X fail:
- bluez_skb_free(skb);
-
+ kfree_skb(skb);
X return err;
X }
+
X /* --------- L2CAP signalling commands --------- */
-static __inline__ __u8 l2cap_get_ident(struct l2cap_conn *conn)
+static inline __u8 l2cap_get_ident(struct l2cap_conn *conn)
X {
X __u8 id;
X
@@ -1344,7 +1445,7 @@
X return id;
X }
X
-static __inline__ struct sk_buff *l2cap_build_cmd(__u8 code, __u8 ident, __u16 len, void *data)
+static inline struct sk_buff *l2cap_build_cmd(__u8 code, __u8 ident, __u16 len, void *data)
X {
X struct sk_buff *skb;
X l2cap_cmd_hdr *cmd;
@@ -1382,7 +1483,6 @@
X ident = l2cap_get_ident(conn);
X if (!(skb = l2cap_build_cmd(code, ident, len, data)))
X return -ENOMEM;
- skb->dev = (void *) conn->iff->hdev;
X return hci_send_acl(conn->hconn, skb, 0);
X }
X
@@ -1394,13 +1494,10 @@
X
X if (!(skb = l2cap_build_cmd(code, ident, len, data)))
X return -ENOMEM;
-
- skb->dev = (void *) conn->iff->hdev;
-
X return hci_send_acl(conn->hconn, skb, 0);
X }
X
-static __inline__ int l2cap_get_conf_opt(__u8 **ptr, __u8 *type, __u32 *val)
+static inline int l2cap_get_conf_opt(__u8 **ptr, __u8 *type, __u32 *val)
X {
X l2cap_conf_opt *opt = (l2cap_conf_opt *) (*ptr);
X int len;
@@ -1433,9 +1530,9 @@
X return len;
X }
X
-static __inline__ void l2cap_parse_conf_req(struct sock *sk, char *data, int len)
+static inline void l2cap_parse_conf_req(struct sock *sk, char *data, int len)
X {
- __u8 type; __u32 val;
+ __u8 type, hint; __u32 val;
X __u8 *ptr = data;
X
X DBG("sk %p len %d", sk, len);
@@ -1443,6 +1540,9 @@
X while (len >= L2CAP_CONF_OPT_SIZE) {
X len -= l2cap_get_conf_opt(&ptr, &type, &val);
X
+ hint = type & 0x80;
+ type &= 0x7f;
+
X switch (type) {
X case L2CAP_CONF_MTU:
X l2cap_pi(sk)->conf_mtu = val;
@@ -1454,11 +1554,18 @@
X
X case L2CAP_CONF_QOS:
X break;
+
+ default:
+ if (hint)
+ break;
+
+ /* FIXME: Reject unknon option */
+ break;
X };
X }
X }
X
-static __inline__ void l2cap_add_conf_opt(__u8 **ptr, __u8 type, __u8 len, __u32 val)
+static inline void l2cap_add_conf_opt(__u8 **ptr, __u8 type, __u8 len, __u32 val)
X {
X register l2cap_conf_opt *opt = (l2cap_conf_opt *) (*ptr);
X
@@ -1540,7 +1647,7 @@
X return ptr - data;
X }
X
-static __inline__ int l2cap_connect_req(struct l2cap_conn *conn, l2cap_cmd_hdr *cmd, __u8 *data)
+static inline int l2cap_connect_req(struct l2cap_conn *conn, l2cap_cmd_hdr *cmd, __u8 *data)
X {
X struct l2cap_chan_list *list = &conn->chan_list;
X l2cap_conn_req *req = (l2cap_conn_req *) data;
@@ -1605,7 +1712,7 @@
X return 0;
X }
X
-static __inline__ int l2cap_connect_rsp(struct l2cap_conn *conn, l2cap_cmd_hdr *cmd, __u8 *data)
+static inline int l2cap_connect_rsp(struct l2cap_conn *conn, l2cap_cmd_hdr *cmd, __u8 *data)
X {
X l2cap_conn_rsp *rsp = (l2cap_conn_rsp *) data;
X __u16 scid, dcid, result, status;
@@ -1626,8 +1733,9 @@
X if (!result) {
X char req[64];
X
- l2cap_pi(sk)->dcid = dcid;
X sk->state = BT_CONFIG;
+ l2cap_pi(sk)->dcid = dcid;
+ l2cap_pi(sk)->conf_state |= CONF_REQ_SENT;
X
X l2cap_send_req(conn, L2CAP_CONF_REQ, l2cap_build_conf_req(sk, req), req);
X } else {
@@ -1638,7 +1746,7 @@
X return 0;
X }
X
-static __inline__ int l2cap_config_req(struct l2cap_conn *conn, l2cap_cmd_hdr *cmd, __u8 *data)
+static inline int l2cap_config_req(struct l2cap_conn *conn, l2cap_cmd_hdr *cmd, __u8 *data)
X {
X l2cap_conf_req * req = (l2cap_conf_req *) data;
X __u16 dcid, flags;
@@ -1671,12 +1779,12 @@
X goto unlock;
X
X /* Output config done */
- l2cap_pi(sk)->conf_state |= CONF_OUTPUT;
+ l2cap_pi(sk)->conf_state |= CONF_OUTPUT_DONE;
X
- if (l2cap_pi(sk)->conf_state == CONF_DONE) {
+ if (l2cap_pi(sk)->conf_state & CONF_INPUT_DONE) {
X sk->state = BT_CONNECTED;
X l2cap_chan_ready(sk);
- } else {
+ } else if (!(l2cap_pi(sk)->conf_state & CONF_REQ_SENT)) {
X char req[64];
X l2cap_send_req(conn, L2CAP_CONF_REQ, l2cap_build_conf_req(sk, req), req);
X }
@@ -1687,7 +1795,7 @@
X return 0;
X }
X
-static __inline__ int l2cap_config_rsp(struct l2cap_conn *conn, l2cap_cmd_hdr *cmd, __u8 *data)
+static inline int l2cap_config_rsp(struct l2cap_conn *conn, l2cap_cmd_hdr *cmd, __u8 *data)
X {
X l2cap_conf_rsp *rsp = (l2cap_conf_rsp *)data;
X __u16 scid, flags, result;
@@ -1705,11 +1813,6 @@
X
X bh_lock_sock(sk);
X
- if (sk->state != BT_CONFIG) {
- err = -EINVAL;
- goto done;
- }
-
X if (result) {
X l2cap_disconn_req req;
X
@@ -1722,7 +1825,7 @@
X req.scid = __cpu_to_le16(l2cap_pi(sk)->scid);
X l2cap_send_req(conn, L2CAP_DISCONN_REQ, L2CAP_DISCONN_REQ_SIZE, &req);
X
- l2cap_set_timer(sk, sk->sndtimeo);
+ l2cap_sock_set_timer(sk, sk->sndtimeo);
X goto done;
X }
X
@@ -1730,9 +1833,9 @@
X goto done;
X
X /* Input config done */
- l2cap_pi(sk)->conf_state |= CONF_INPUT;
+ l2cap_pi(sk)->conf_state |= CONF_INPUT_DONE;
X
- if (l2cap_pi(sk)->conf_state == CONF_DONE) {
+ if (l2cap_pi(sk)->conf_state & CONF_OUTPUT_DONE) {
X sk->state = BT_CONNECTED;
X l2cap_chan_ready(sk);
X }
@@ -1743,7 +1846,7 @@
X return err;
X }
X
-static __inline__ int l2cap_disconnect_req(struct l2cap_conn *conn, l2cap_cmd_hdr *cmd, __u8 *data)
+static inline int l2cap_disconnect_req(struct l2cap_conn *conn, l2cap_cmd_hdr *cmd, __u8 *data)
X {
X l2cap_disconn_req *req = (l2cap_disconn_req *) data;
X l2cap_disconn_rsp rsp;
@@ -1773,7 +1876,7 @@
X return 0;
X }
X
-static __inline__ int l2cap_disconnect_rsp(struct l2cap_conn *conn, l2cap_cmd_hdr *cmd, __u8 *data)
+static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, l2cap_cmd_hdr *cmd, __u8 *data)
X {
X l2cap_disconn_rsp *rsp = (l2cap_disconn_rsp *) data;
X __u16 dcid, scid;
@@ -1788,7 +1891,7 @@
X return -ENOENT;
X
X bh_lock_sock(sk);
- l2cap_clear_timer(sk);
+ l2cap_sock_clear_timer(sk);
X l2cap_chan_del(sk, ECONNABORTED);
X bh_unlock_sock(sk);
X
@@ -1797,7 +1900,7 @@
X return 0;
X }
X
-static __inline__ void l2cap_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb)
+static inline void l2cap_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb)
X {
X __u8 *data = skb->data;
X int len = skb->len;
@@ -1809,7 +1912,7 @@
X data += L2CAP_CMD_HDR_SIZE;
X len -= L2CAP_CMD_HDR_SIZE;
X
- cmd.len = le16_to_cpu(cmd.len);
+ cmd.len = __le16_to_cpu(cmd.len);
X
X DBG("code 0x%2.2x len %d id 0x%2.2x", cmd.code, cmd.len, cmd.ident);
X
@@ -1869,7 +1972,7 @@
X DBG("error %d", err);
X
X /* FIXME: Map err to a valid reason. */
- rej.reason = cpu_to_le16(0);
+ rej.reason = __cpu_to_le16(0);
X l2cap_send_rsp(conn, cmd.ident, L2CAP_COMMAND_REJ, L2CAP_CMD_REJ_SIZE, &rej);
X }
X
@@ -1877,10 +1980,10 @@
X len -= cmd.len;
X }
X
- bluez_skb_free(skb);
+ kfree_skb(skb);
X }
X
-static __inline__ int l2cap_data_channel(struct l2cap_conn *conn, __u16 cid, struct sk_buff *skb)
+static inline int l2cap_data_channel(struct l2cap_conn *conn, __u16 cid, struct sk_buff *skb)
X {
X struct sock *sk;
X
@@ -1903,7 +2006,7 @@
X return 0;
X
X drop:
- bluez_skb_free(skb);
+ kfree_skb(skb);
X
X return 0;
X }
@@ -1914,8 +2017,8 @@
X __u16 cid, len;
X
X skb_pull(skb, L2CAP_HDR_SIZE);
- cid = le16_to_cpu(lh->cid);
- len = le16_to_cpu(lh->len);
+ cid = __le16_to_cpu(lh->cid);
+ len = __le16_to_cpu(lh->len);
X
X DBG("len %d, cid 0x%4.4x", len, cid);
X
@@ -2008,10 +2111,10 @@
X goto done;
X }
X
- conn->state = BT_CONNECTED;
X conn->hconn = hconn;
-
X hconn->l2cap_data = (void *)conn;
+
+ conn->state = BT_CONNECTED;
X }
X
X done:
@@ -2044,7 +2147,7 @@
X struct l2cap_conn *conn = hconn->l2cap_data;
X
X if (!conn) {
- ERR("unknown connection");
+ ERR("unknown connection %p", hconn);
X goto drop;
X }
X
@@ -2054,8 +2157,14 @@
X int flen, tlen, size;
X l2cap_hdr *lh;
X
+ if (conn->rx_len) {
+ ERR("Unexpected start frame (len %d)", skb->len);
+ kfree_skb(conn->rx_skb); conn->rx_skb = NULL;
+ conn->rx_len = 0;
+ }
+
X if (skb->len < L2CAP_HDR_SIZE) {
- DBG("Corrupted L2CAP frame %d", skb->len);
+ ERR("Frame is too small (len %d)", skb->len);
X goto drop;
X }
X
@@ -2082,12 +2191,14 @@
X } else {
X DBG("Cont: frag len %d (expecting %d)", skb->len, conn->rx_len);
X
- /* Check length */
+ if (!conn->rx_len) {
+ ERR("Unexpected continuation frame (len %d)", skb->len);
+ goto drop;
+ }
+
X if (skb->len > conn->rx_len) {
- if (conn->rx_skb) {
- bluez_skb_free(conn->rx_skb);
- conn->rx_skb = NULL;
- }
+ ERR("Fragment is too large (len %d)", skb->len);
+ kfree_skb(conn->rx_skb); conn->rx_skb = NULL;
X goto drop;
X }
X
@@ -2098,13 +2209,11 @@
X /* Complete frame received */
X l2cap_recv_frame(conn, conn->rx_skb);
X conn->rx_skb = NULL;
- conn->rx_len = 0;
X }
X }
X
X drop:
- bluez_skb_free(skb);
-
+ kfree_skb(skb);
X return 0;
X }
X
@@ -2118,7 +2227,7 @@
X getname: l2cap_sock_getname,
X sendmsg: l2cap_sock_sendmsg,
X recvmsg: l2cap_sock_recvmsg,
- poll: datagram_poll,
+ poll: l2cap_sock_poll,
X socketpair: sock_no_socketpair,
X ioctl: sock_no_ioctl,
X shutdown: sock_no_shutdown,
@@ -2148,7 +2257,7 @@
X int __init l2cap_init(void)
X {
X INF("BlueZ L2CAP ver %s Copyright (C) 2000,2001 Qualcomm Inc",
- BLUEZ_VER);
+ VERSION);
X INF("Written 2000,2001 by Maxim Krasnyansky <ma...@qualcomm.com>");
X
X if (bluez_sock_register(BTPROTO_L2CAP, &l2cap_sock_family_ops)) {
@@ -2200,3 +2309,6 @@
X
X module_init(l2cap_init);
X module_exit(l2cap_cleanup);
+
+MODULE_AUTHOR("Maxim Krasnyansky <ma...@qualcomm.com>");
+MODULE_DESCRIPTION("BlueZ L2CAP ver " VERSION);
diff -u --recursive --new-file v2.4.9/linux/net/bluetooth/l2cap_proc.c linux/net/bluetooth/l2cap_proc.c
--- v2.4.9/linux/net/bluetooth/l2cap_proc.c Tue Jul 3 17:08:22 2001
+++ linux/net/bluetooth/l2cap_proc.c Fri Sep 7 09:28:38 2001
@@ -25,7 +25,7 @@
X /*
X * BlueZ L2CAP proc fs support.
X *
- * $Id: l2cap_proc.c,v 1.1 2001/06/01 08:12:11 davem Exp $
+ * $Id: l2cap_proc.c,v 1.2 2001/06/02 01:40:09 maxk Exp $
X */
X
X #include <linux/config.h>
@@ -36,7 +36,7 @@
X #include <linux/kernel.h>
X #include <linux/major.h>
X #include <linux/sched.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
X #include <linux/poll.h>
X #include <linux/fcntl.h>
X #include <linux/init.h>
diff -u --recursive --new-file v2.4.9/linux/net/bluetooth/lib.c linux/net/bluetooth/lib.c
--- v2.4.9/linux/net/bluetooth/lib.c Tue Jul 3 17:08:22 2001
+++ linux/net/bluetooth/lib.c Fri Sep 7 09:28:38 2001
@@ -25,7 +25,7 @@
X /*
X * BlueZ kernel library.
X *
- * $Id: lib.c,v 1.1 2001/06/01 08:12:11 davem Exp $
+ * $Id: lib.c,v 1.3 2001/06/22 23:14:23 maxk Exp $
X */
X
X #include <linux/kernel.h>
@@ -76,7 +76,8 @@
X
X i ^= 1;
X sprintf(str[i], "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
- ba->b0, ba->b1, ba->b2, ba->b3, ba->b4, ba->b5);
+ ba->b[0], ba->b[1], ba->b[2],
+ ba->b[3], ba->b[4], ba->b[5]);
X
X return str[i];
X }
diff -u --recursive --new-file v2.4.9/linux/net/bluetooth/syms.c linux/net/bluetooth/syms.c
--- v2.4.9/linux/net/bluetooth/syms.c Tue Jul 3 17:08:22 2001
+++ linux/net/bluetooth/syms.c Fri Sep 7 09:28:38 2001
@@ -25,7 +25,7 @@
X /*
X * BlueZ symbols.
X *
- * $Id: syms.c,v 1.1 2001/06/01 08:12:11 davem Exp $
+ * $Id: syms.c,v 1.1 2001/07/12 19:31:24 maxk Exp $
X */
X
X #include <linux/config.h>
diff -u --recursive --new-file v2.4.9/linux/net/core/dev.c linux/net/core/dev.c
--- v2.4.9/linux/net/core/dev.c Sun Aug 12 13:28:01 2001
+++ linux/net/core/dev.c Thu Sep 20 14:12:56 2001
@@ -1217,10 +1217,9 @@
X enqueue:
X dev_hold(skb->dev);
X __skb_queue_tail(&queue->input_pkt_queue,skb);
- local_irq_restore(flags);
-
X /* Runs from irqs or BH's, no need to wake BH */
- __cpu_raise_softirq(this_cpu, NET_RX_SOFTIRQ);
+ cpu_raise_softirq(this_cpu, NET_RX_SOFTIRQ);
+ local_irq_restore(flags);
X #ifndef OFFLINE_SAMPLE
X get_sample_stats(this_cpu);
X #endif
@@ -1529,10 +1528,9 @@
X
X local_irq_disable();
X netdev_rx_stat[this_cpu].time_squeeze++;
- local_irq_enable();
-
X /* This already runs in BH context, no need to wake up BH's */
- __cpu_raise_softirq(this_cpu, NET_RX_SOFTIRQ);
+ cpu_raise_softirq(this_cpu, NET_RX_SOFTIRQ);
+ local_irq_enable();
X
X NET_PROFILE_LEAVE(softnet_process);
X return;
@@ -2279,6 +2277,32 @@
X * These ioctl calls:
X * - require superuser power.
X * - require strict serialization.
+ * - return a value
+ */
+
+ case SIOCETHTOOL:
+ case SIOCGMIIPHY:
+ case SIOCGMIIREG:
+ if (!capable(CAP_NET_ADMIN))
+ return -EPERM;
+ dev_load(ifr.ifr_name);
+ dev_probe_lock();
+ rtnl_lock();
+ ret = dev_ifsioc(&ifr, cmd);
+ rtnl_unlock();
+ dev_probe_unlock();
+ if (!ret) {
+ if (colon)
+ *colon = ':';
+ if (copy_to_user(arg, &ifr, sizeof(struct ifreq)))
+ return -EFAULT;
+ }
+ return ret;
+
+ /*
+ * These ioctl calls:
+ * - require superuser power.
+ * - require strict serialization.
X * - do not return a value
X */
X
@@ -2293,9 +2317,6 @@
X case SIOCSIFHWBROADCAST:
X case SIOCSIFTXQLEN:
X case SIOCSIFNAME:
- case SIOCETHTOOL:
- case SIOCGMIIPHY:
- case SIOCGMIIREG:
X case SIOCSMIIREG:
X if (!capable(CAP_NET_ADMIN))
X return -EPERM;
@@ -2424,8 +2445,12 @@
X dev->iflink = -1;
X
X /* Init, if this function is available */
- if (dev->init && dev->init(dev) != 0)
+ if (dev->init && dev->init(dev) != 0) {
+#ifdef CONFIG_NET_DIVERT
+ free_divert_blk(dev);
+#endif
X return -EIO;
+ }
X
X dev->ifindex = dev_new_index();
X if (dev->iflink == -1)
@@ -2434,6 +2459,9 @@
X /* Check for existence, and append to tail of chain */
X for (dp=&dev_base; (d=*dp) != NULL; dp=&d->next) {
X if (d == dev || strcmp(d->name, dev->name) == 0) {
+#ifdef CONFIG_NET_DIVERT
+ free_divert_blk(dev);
+#endif
X return -EEXIST;
X }
X }
diff -u --recursive --new-file v2.4.9/linux/net/core/iovec.c linux/net/core/iovec.c
--- v2.4.9/linux/net/core/iovec.c Mon Aug 27 12:41:49 2001
+++ linux/net/core/iovec.c Mon Sep 10 07:57:00 2001
@@ -87,7 +87,7 @@
X {
X if(iov->iov_len)
X {
- int copy = min(unsigned int, iov->iov_len, len);
+ int copy = min_t(unsigned int, iov->iov_len, len);
X if (copy_to_user(iov->iov_base, kdata, copy))
X goto out;
X kdata+=copy;
@@ -114,7 +114,7 @@
X {
X if(iov->iov_len)
X {
- int copy = min(unsigned int, iov->iov_len, len);
+ int copy = min_t(unsigned int, iov->iov_len, len);
X memcpy(iov->iov_base, kdata, copy);
X kdata+=copy;
X len-=copy;
@@ -140,7 +140,7 @@
X {
X if(iov->iov_len)
X {
- int copy = min(unsigned int, len, iov->iov_len);
+ int copy = min_t(unsigned int, len, iov->iov_len);
X if (copy_from_user(kdata, iov->iov_base, copy))
X goto out;
X len-=copy;
@@ -175,7 +175,7 @@
X while (len > 0)
X {
X u8 *base = iov->iov_base + offset;
- int copy = min(unsigned int, len, iov->iov_len - offset);
+ int copy = min_t(unsigned int, len, iov->iov_len - offset);
X
X offset = 0;
X if (copy_from_user(kdata, base, copy))
@@ -214,7 +214,7 @@
X while (len > 0)
X {
X u8 *base = iov->iov_base + offset;
- int copy = min(unsigned int, len, iov->iov_len - offset);
+ int copy = min_t(unsigned int, len, iov->iov_len - offset);
X
X offset = 0;
X /* There is a remnant from previous iov. */
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/arp.c linux/net/ipv4/arp.c
--- v2.4.9/linux/net/ipv4/arp.c Wed May 16 10:21:45 2001
+++ linux/net/ipv4/arp.c Fri Sep 7 11:01:20 2001
@@ -1,6 +1,6 @@
X /* linux/net/inet/arp.c
X *
- * Version: $Id: arp.c,v 1.98 2001/05/16 16:45:35 davem Exp $
+ * Version: $Id: arp.c,v 1.99 2001/08/30 22:55:42 davem Exp $
X *
X * Copyright (C) 1994 by Florian La Roche
X *
@@ -560,7 +560,6 @@
X memset(arp_ptr, 0, dev->addr_len);
X arp_ptr+=dev->addr_len;
X memcpy(arp_ptr, &dest_ip, 4);
- skb->dev = dev;
X
X dev_queue_xmit(skb);
X return;
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/icmp.c linux/net/ipv4/icmp.c
--- v2.4.9/linux/net/ipv4/icmp.c Sun Aug 12 13:28:01 2001
+++ linux/net/ipv4/icmp.c Fri Sep 7 11:01:21 2001
@@ -3,7 +3,7 @@
X *
X * Alan Cox, <al...@redhat.com>
X *
- * Version: $Id: icmp.c,v 1.79 2001/08/03 22:20:39 davem Exp $
+ * Version: $Id: icmp.c,v 1.81 2001/09/01 00:31:50 davem Exp $
X *
X * This program is free software; you can redistribute it and/or
X * modify it under the terms of the GNU General Public License
@@ -16,6 +16,9 @@
X * Other than that this module is a complete rewrite.
X *
X * Fixes:
+ * Clemens Fruhwirth : introduce global icmp rate limiting
+ * with icmp type masking ability instead
+ * of broken per type icmp timeouts.
X * Mike Shaver : RFC1122 checks.
X * Alan Cox : Multicast ping reply as self.
X * Alan Cox : Fix atomicity lockup in ip_build_xmit
@@ -143,6 +146,21 @@
X /* Control parameter - ignore bogus broadcast responses? */
X int sysctl_icmp_ignore_bogus_error_responses;
X
+/*
+ * Configurable global rate limit.
+ *
+ * ratelimit defines tokens/packet consumed for dst->rate_token bucket
+ * ratemask defines which icmp types are ratelimited by setting
+ * it's bit position.
+ *
+ * default:
+ * dest unreachable (0x03), source quench (0x04),
+ * time exceeded (0x11), parameter problem (0x12)
+ */
+
+int sysctl_icmp_ratelimit = 1*HZ;
+int sysctl_icmp_ratemask = 0x1818;
+
X /*
X * ICMP control array. This specifies what to do with each ICMP.
X */
@@ -153,7 +171,6 @@
X unsigned long *input; /* Address to increment on input */
X void (*handler)(struct sk_buff *skb);
X short error; /* This ICMP is classed as an error message */
- int *timeout; /* Rate limit */
X };
X
X static struct icmp_control icmp_pointers[NR_ICMP_TYPES+1];
@@ -221,11 +238,6 @@
X * Note that the same dst_entry fields are modified by functions in
X * route.c too, but these work for packet destinations while xrlim_allow
X * works for icmp destinations. This means the rate limiting information
- * for one "ip object" is shared.
- *
- * Note that the same dst_entry fields are modified by functions in
- * route.c too, but these work for packet destinations while xrlim_allow
- * works for icmp destinations. This means the rate limiting information
X * for one "ip object" is shared - and these ICMPs are twice limited:
X * by source and by destination.
X *
@@ -238,15 +250,12 @@
X int xrlim_allow(struct dst_entry *dst, int timeout)
X {
X unsigned long now;
- static int burst = HZ;
X
X now = jiffies;
X dst->rate_tokens += now - dst->rate_last;
X dst->rate_last = now;
- if (burst < XRLIM_BURST_FACTOR*timeout)
- burst = XRLIM_BURST_FACTOR*timeout;
- if (dst->rate_tokens > burst)
- dst->rate_tokens = burst;
+ if (dst->rate_tokens > XRLIM_BURST_FACTOR*timeout)
+ dst->rate_tokens = XRLIM_BURST_FACTOR*timeout;
X if (dst->rate_tokens >= timeout) {
X dst->rate_tokens -= timeout;
X return 1;
@@ -258,22 +267,22 @@
X {
X struct dst_entry *dst = &rt->u.dst;
X
- if (type > NR_ICMP_TYPES || !icmp_pointers[type].timeout)
+ if (type > NR_ICMP_TYPES)
X return 1;
X
X /* Don't limit PMTU discovery. */
X if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED)
X return 1;
X
- /* Redirect has its own rate limit mechanism */
- if (type == ICMP_REDIRECT)
- return 1;
-
X /* No rate limit on loopback */
X if (dst->dev && (dst->dev->flags&IFF_LOOPBACK))
X return 1;
X
- return xrlim_allow(dst, *(icmp_pointers[type].timeout));
+ /* Limit if icmp type is enabled in ratemask. */
+ if((1 << type) & sysctl_icmp_ratemask)
+ return xrlim_allow(dst, sysctl_icmp_ratelimit);
+ else
+ return 1;
X }
X
X /*
@@ -876,7 +885,7 @@
X case CHECKSUM_HW:
X if ((u16)csum_fold(skb->csum) == 0)
X break;
- NETDEBUG(printk(KERN_DEBUG "icmp v4 hw csum failure\n"));
+ NETDEBUG(if (net_ratelimit()) printk(KERN_DEBUG "icmp v4 hw csum failure\n"));
X case CHECKSUM_NONE:
X if ((u16)csum_fold(skb_checksum(skb, 0, skb->len, 0)))
X goto error;
@@ -929,57 +938,43 @@
X goto drop;
X }
X
-
-/*
- * Configurable rate limits.
- * Someone should check if these default values are correct.
- * Note that these values interact with the routing cache GC timeout.
- * If you chose them too high they won't take effect, because the
- * dst_entry gets expired too early. The same should happen when
- * the cache grows too big.
- */
-int sysctl_icmp_destunreach_time = 1*HZ;
-int sysctl_icmp_timeexceed_time = 1*HZ;
-int sysctl_icmp_paramprob_time = 1*HZ;
-int sysctl_icmp_echoreply_time; /* don't limit it per default. */
-
X /*
X * This table is the definition of how we handle ICMP.
X */
X
X static struct icmp_control icmp_pointers[NR_ICMP_TYPES+1] = {
X /* ECHO REPLY (0) */
- { &icmp_statistics[0].IcmpOutEchoReps, &icmp_statistics[0].IcmpInEchoReps, icmp_discard, 0, &sysctl_icmp_echoreply_time},
- { &icmp_statistics[0].dummy, &icmp_statistics[0].IcmpInErrors, icmp_discard, 1, },
- { &icmp_statistics[0].dummy, &icmp_statistics[0].IcmpInErrors, icmp_discard, 1, },
+ { &icmp_statistics[0].IcmpOutEchoReps, &icmp_statistics[0].IcmpInEchoReps, icmp_discard, 0 },
+ { &icmp_statistics[0].dummy, &icmp_statistics[0].IcmpInErrors, icmp_discard, 1 },
+ { &icmp_statistics[0].dummy, &icmp_statistics[0].IcmpInErrors, icmp_discard, 1 },
X /* DEST UNREACH (3) */
- { &icmp_statistics[0].IcmpOutDestUnreachs, &icmp_statistics[0].IcmpInDestUnreachs, icmp_unreach, 1, &sysctl_icmp_destunreach_time },
+ { &icmp_statistics[0].IcmpOutDestUnreachs, &icmp_statistics[0].IcmpInDestUnreachs, icmp_unreach, 1 },
X /* SOURCE QUENCH (4) */
- { &icmp_statistics[0].IcmpOutSrcQuenchs, &icmp_statistics[0].IcmpInSrcQuenchs, icmp_unreach, 1, },
+ { &icmp_statistics[0].IcmpOutSrcQuenchs, &icmp_statistics[0].IcmpInSrcQuenchs, icmp_unreach, 1 },
X /* REDIRECT (5) */
- { &icmp_statistics[0].IcmpOutRedirects, &icmp_statistics[0].IcmpInRedirects, icmp_redirect, 1, },
- { &icmp_statistics[0].dummy, &icmp_statistics[0].IcmpInErrors, icmp_discard, 1, },
- { &icmp_statistics[0].dummy, &icmp_statistics[0].IcmpInErrors, icmp_discard, 1, },
+ { &icmp_statistics[0].IcmpOutRedirects, &icmp_statistics[0].IcmpInRedirects, icmp_redirect, 1 },
+ { &icmp_statistics[0].dummy, &icmp_statistics[0].IcmpInErrors, icmp_discard, 1 },
+ { &icmp_statistics[0].dummy, &icmp_statistics[0].IcmpInErrors, icmp_discard, 1 },
X /* ECHO (8) */
- { &icmp_statistics[0].IcmpOutEchos, &icmp_statistics[0].IcmpInEchos, icmp_echo, 0, },
- { &icmp_statistics[0].dummy, &icmp_statistics[0].IcmpInErrors, icmp_discard, 1, },
- { &icmp_statistics[0].dummy, &icmp_statistics[0].IcmpInErrors, icmp_discard, 1, },
+ { &icmp_statistics[0].IcmpOutEchos, &icmp_statistics[0].IcmpInEchos, icmp_echo, 0 },
+ { &icmp_statistics[0].dummy, &icmp_statistics[0].IcmpInErrors, icmp_discard, 1 },
+ { &icmp_statistics[0].dummy, &icmp_statistics[0].IcmpInErrors, icmp_discard, 1 },
X /* TIME EXCEEDED (11) */
- { &icmp_statistics[0].IcmpOutTimeExcds, &icmp_statistics[0].IcmpInTimeExcds, icmp_unreach, 1, &sysctl_icmp_timeexceed_time },
+ { &icmp_statistics[0].IcmpOutTimeExcds, &icmp_statistics[0].IcmpInTimeExcds, icmp_unreach, 1 },
X /* PARAMETER PROBLEM (12) */
- { &icmp_statistics[0].IcmpOutParmProbs, &icmp_statistics[0].IcmpInParmProbs, icmp_unreach, 1, &sysctl_icmp_paramprob_time },
+ { &icmp_statistics[0].IcmpOutParmProbs, &icmp_statistics[0].IcmpInParmProbs, icmp_unreach, 1 },
X /* TIMESTAMP (13) */
- { &icmp_statistics[0].IcmpOutTimestamps, &icmp_statistics[0].IcmpInTimestamps, icmp_timestamp, 0, },
+ { &icmp_statistics[0].IcmpOutTimestamps, &icmp_statistics[0].IcmpInTimestamps, icmp_timestamp, 0 },
X /* TIMESTAMP REPLY (14) */
- { &icmp_statistics[0].IcmpOutTimestampReps, &icmp_statistics[0].IcmpInTimestampReps, icmp_discard, 0, },
+ { &icmp_statistics[0].IcmpOutTimestampReps, &icmp_statistics[0].IcmpInTimestampReps, icmp_discard, 0 },
X /* INFO (15) */
- { &icmp_statistics[0].dummy, &icmp_statistics[0].dummy, icmp_discard, 0, },
+ { &icmp_statistics[0].dummy, &icmp_statistics[0].dummy, icmp_discard, 0 },
X /* INFO REPLY (16) */
- { &icmp_statistics[0].dummy, &icmp_statistics[0].dummy, icmp_discard, 0, },
+ { &icmp_statistics[0].dummy, &icmp_statistics[0].dummy, icmp_discard, 0 },
X /* ADDR MASK (17) */
- { &icmp_statistics[0].IcmpOutAddrMasks, &icmp_statistics[0].IcmpInAddrMasks, icmp_address, 0, },
+ { &icmp_statistics[0].IcmpOutAddrMasks, &icmp_statistics[0].IcmpInAddrMasks, icmp_address, 0 },
X /* ADDR MASK REPLY (18) */
- { &icmp_statistics[0].IcmpOutAddrMaskReps, &icmp_statistics[0].IcmpInAddrMaskReps, icmp_address_reply, 0, }
+ { &icmp_statistics[0].IcmpOutAddrMaskReps, &icmp_statistics[0].IcmpInAddrMaskReps, icmp_address_reply, 0 }
X };
X
X void __init icmp_init(struct net_proto_family *ops)
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/ip_fragment.c linux/net/ipv4/ip_fragment.c
--- v2.4.9/linux/net/ipv4/ip_fragment.c Thu Apr 12 12:11:39 2001
+++ linux/net/ipv4/ip_fragment.c Fri Sep 7 11:01:21 2001
@@ -5,7 +5,7 @@
X *
X * The IP fragmentation functionality.
X *
- * Version: $Id: ip_fragment.c,v 1.57 2001/03/07 22:00:57 davem Exp $
+ * Version: $Id: ip_fragment.c,v 1.58 2001/09/01 00:31:50 davem Exp $
X *
X * Authors: Fred N. van Kempen <wal...@uWalt.NL.Mugnet.ORG>
X * Alan Cox <Alan...@linux.org>
@@ -335,7 +335,7 @@
X return ip_frag_intern(hash, qp);
X
X out_nomem:
- NETDEBUG(printk(KERN_ERR "ip_frag_create: no memory left !\n"));
+ NETDEBUG(if (net_ratelimit()) printk(KERN_ERR "ip_frag_create: no memory left !\n"));
X return NULL;
X }
X
@@ -578,7 +578,8 @@
X return head;
X
X out_nomem:
- NETDEBUG(printk(KERN_ERR
+ NETDEBUG(if (net_ratelimit())
+ printk(KERN_ERR
X "IP: queue_glue: no memory for gluing queue %p\n",
X qp));
X goto out_fail;
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/ip_options.c linux/net/ipv4/ip_options.c
--- v2.4.9/linux/net/ipv4/ip_options.c Wed Aug 9 13:51:09 2000
+++ linux/net/ipv4/ip_options.c Fri Sep 7 11:01:21 2001
@@ -5,7 +5,7 @@
X *
X * The options processing module for ip.c
X *
- * Version: $Id: ip_options.c,v 1.20 2000/08/09 09:17:00 davem Exp $
+ * Version: $Id: ip_options.c,v 1.21 2001/09/01 00:31:50 davem Exp $
X *
X * Authors: A.N.Kuznetsov
X *
@@ -549,7 +549,7 @@
X ip_rt_get_source(&optptr[srrptr-1], rt);
X skb->nh.iph->daddr = rt->rt_dst;
X optptr[2] = srrptr+4;
- } else
+ } else if (net_ratelimit())
X printk(KERN_CRIT "ip_forward(): Argh! Destination lost!\n");
X if (opt->ts_needaddr) {
X optptr = raw + opt->ts;
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/ip_output.c linux/net/ipv4/ip_output.c
--- v2.4.9/linux/net/ipv4/ip_output.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipv4/ip_output.c Fri Sep 7 11:01:21 2001
@@ -5,7 +5,7 @@
X *
X * The Internet Protocol (IP) output module.
X *
- * Version: $Id: ip_output.c,v 1.97 2001/08/09 17:53:40 davem Exp $
+ * Version: $Id: ip_output.c,v 1.98 2001/09/01 00:31:50 davem Exp $
X *
X * Authors: Ross Biro, <bi...@leland.Stanford.Edu>
X * Fred N. van Kempen, <wal...@uWalt.NL.Mugnet.ORG>
@@ -174,7 +174,8 @@
X } else if (dst->neighbour)
X return dst->neighbour->output(skb);
X
- printk(KERN_DEBUG "khm\n");
+ if (net_ratelimit())
+ printk(KERN_DEBUG "ip_finish_output2: No header cache and no neighbour!\n");
X kfree_skb(skb);
X return -EINVAL;
X }
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/ip_sockglue.c linux/net/ipv4/ip_sockglue.c
--- v2.4.9/linux/net/ipv4/ip_sockglue.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipv4/ip_sockglue.c Thu Sep 20 14:12:56 2001
@@ -5,7 +5,7 @@
X *
X * The IP to API glue.
X *
- * Version: $Id: ip_sockglue.c,v 1.59 2001/08/13 18:56:12 davem Exp $
+ * Version: $Id: ip_sockglue.c,v 1.60 2001/09/18 22:29:09 davem Exp $
X *
X * Authors: see ip.c
X *
@@ -683,7 +683,7 @@
X
X ip_options_undo(opt);
X
- len = min(unsigned int, len, opt->optlen);
+ len = min_t(unsigned int, len, opt->optlen);
X if(put_user(len, optlen))
X return -EFAULT;
X if(copy_to_user(optval, opt->__data, len))
@@ -744,7 +744,7 @@
X case IP_MULTICAST_IF:
X {
X struct in_addr addr;
- len = min(unsigned int, len, sizeof(struct in_addr));
+ len = min_t(unsigned int, len, sizeof(struct in_addr));
X addr.s_addr = sk->protinfo.af_inet.mc_addr;
X release_sock(sk);
X
@@ -808,7 +808,7 @@
X if(copy_to_user(optval,&ucval,1))
X return -EFAULT;
X } else {
- len = min(unsigned int, sizeof(int), len);
+ len = min_t(unsigned int, sizeof(int), len);
X if(put_user(len, optlen))
X return -EFAULT;
X if(copy_to_user(optval,&val,len))
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/ipip.c linux/net/ipv4/ipip.c
--- v2.4.9/linux/net/ipv4/ipip.c Thu May 24 15:00:59 2001
+++ linux/net/ipv4/ipip.c Thu Sep 20 14:12:56 2001
@@ -1,7 +1,7 @@
X /*
X * Linux NET3: IP/IP protocol decoder.
X *
- * Version: $Id: ipip.c,v 1.46 2001/05/17 04:12:18 davem Exp $
+ * Version: $Id: ipip.c,v 1.47 2001/09/18 00:36:07 davem Exp $
X *
X * Authors:
X * Sam Lantinga (slo...@cs.ucdavis.edu) 02/01/95
@@ -878,7 +878,7 @@
X name: "IPIP"
X };
X
-static const char banner[] __initdata =
+static char banner[] __initdata =
X KERN_INFO "IPv4 over IPv4 tunneling driver\n";
X
X int __init ipip_init(void)
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/ipmr.c linux/net/ipv4/ipmr.c
--- v2.4.9/linux/net/ipv4/ipmr.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipv4/ipmr.c Thu Sep 20 14:12:56 2001
@@ -9,7 +9,7 @@
X * as published by the Free Software Foundation; either version
X * 2 of the License, or (at your option) any later version.
X *
- * Version: $Id: ipmr.c,v 1.63 2001/08/13 18:56:12 davem Exp $
+ * Version: $Id: ipmr.c,v 1.64 2001/09/18 22:29:09 davem Exp $
X *
X * Fixes:
X * Michael Chastain : Incorrect size of copying.
@@ -979,7 +979,7 @@
X if (get_user(olr, optlen))
X return -EFAULT;
X
- olr = min(unsigned int, olr, sizeof(int));
+ olr = min_t(unsigned int, olr, sizeof(int));
X if (olr < 0)
X return -EINVAL;
X
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/netfilter/ip_conntrack_standalone.c linux/net/ipv4/netfilter/ip_conntrack_standalone.c
--- v2.4.9/linux/net/ipv4/netfilter/ip_conntrack_standalone.c Fri Apr 27 14:15:01 2001
+++ linux/net/ipv4/netfilter/ip_conntrack_standalone.c Fri Sep 14 14:04:08 2001
@@ -226,6 +226,7 @@
X
X static int init_or_cleanup(int init)
X {
+ struct proc_dir_entry *proc;
X int ret = 0;
X
X if (!init) goto cleanup;
@@ -234,11 +235,14 @@
X if (ret < 0)
X goto cleanup_nothing;
X
- proc_net_create("ip_conntrack",0,list_conntracks);
+ proc = proc_net_create("ip_conntrack",0,list_conntracks);
+ if (!proc) goto cleanup_init;
+ proc->owner = THIS_MODULE;
+
X ret = nf_register_hook(&ip_conntrack_in_ops);
X if (ret < 0) {
X printk("ip_conntrack: can't register in hook.\n");
- goto cleanup_init;
+ goto cleanup_proc;
X }
X ret = nf_register_hook(&ip_conntrack_local_out_ops);
X if (ret < 0) {
@@ -266,8 +270,9 @@
X nf_unregister_hook(&ip_conntrack_local_out_ops);
X cleanup_inops:
X nf_unregister_hook(&ip_conntrack_in_ops);
- cleanup_init:
+ cleanup_proc:
X proc_net_remove("ip_conntrack");
+ cleanup_init:
X ip_conntrack_cleanup();
X cleanup_nothing:
X return ret;
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/netfilter/ip_fw_compat_masq.c linux/net/ipv4/netfilter/ip_fw_compat_masq.c
--- v2.4.9/linux/net/ipv4/netfilter/ip_fw_compat_masq.c Mon Sep 18 15:09:55 2000
+++ linux/net/ipv4/netfilter/ip_fw_compat_masq.c Fri Sep 14 14:04:08 2001
@@ -14,6 +14,7 @@
X #include <linux/inetdevice.h>
X #include <linux/proc_fs.h>
X #include <linux/version.h>
+#include <linux/module.h>
X #include <net/route.h>
X
X #define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_conntrack_lock)
@@ -302,13 +303,22 @@
X int __init masq_init(void)
X {
X int ret;
+ struct proc_dir_entry *proc;
X
X ret = ip_conntrack_init();
X if (ret == 0) {
X ret = ip_nat_init();
- if (ret == 0)
- proc_net_create("ip_masquerade", 0, masq_procinfo);
- else
+ if (ret == 0) {
+ proc = proc_net_create("ip_masquerade",
+ 0, masq_procinfo);
+ if (proc)
+ proc->owner = THIS_MODULE;
+ else {
+ ip_nat_cleanup();
+ ip_conntrack_cleanup();
+ ret = -ENOMEM;
+ }
+ } else
X ip_conntrack_cleanup();
X }
X
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/netfilter/ip_nat_helper.c linux/net/ipv4/netfilter/ip_nat_helper.c
--- v2.4.9/linux/net/ipv4/netfilter/ip_nat_helper.c Fri Apr 27 14:15:01 2001
+++ linux/net/ipv4/netfilter/ip_nat_helper.c Tue Aug 28 07:09:44 2001
@@ -267,8 +267,8 @@
X /* Replace with NOPs. */
X tcph->check
X = ip_nat_cheat_check(*((u_int16_t *)(opt + i))^0xFFFF,
- 0, tcph->check);
- opt[i] = opt[i+1] = 0;
+ (TCPOPT_NOP<<8)|TCPOPT_NOP, tcph->check);
+ opt[i] = opt[i+1] = TCPOPT_NOP;
X }
X else DEBUGP("Something wrong with SACK_PERM.\n");
X }
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/netfilter/ip_queue.c linux/net/ipv4/netfilter/ip_queue.c
--- v2.4.9/linux/net/ipv4/netfilter/ip_queue.c Wed Jul 25 17:10:26 2001
+++ linux/net/ipv4/netfilter/ip_queue.c Fri Sep 14 14:04:08 2001
@@ -492,7 +492,7 @@
X
X #define RCV_SKB_FAIL(err) do { netlink_ack(skb, nlh, (err)); return; } while (0);
X
-extern __inline__ void netlink_receive_user_skb(struct sk_buff *skb)
+static __inline__ void netlink_receive_user_skb(struct sk_buff *skb)
X {
X int status, type;
X struct nlmsghdr *nlh;
@@ -647,6 +647,7 @@
X static int __init init(void)
X {
X int status = 0;
+ struct proc_dir_entry *proc;
X
X nfnl = netlink_kernel_create(NETLINK_FIREWALL, netlink_receive_user_sk);
X if (nfnl == NULL) {
@@ -662,8 +663,14 @@
X sock_release(nfnl->socket);
X return status;
X }
+ proc = proc_net_create(IPQ_PROC_FS_NAME, 0, ipq_get_info);
+ if (proc) proc->owner = THIS_MODULE;
+ else {
+ ipq_destroy_queue(nlq);
+ sock_release(nfnl->socket);
+ return -ENOMEM;
+ }
X register_netdevice_notifier(&ipq_dev_notifier);
- proc_net_create(IPQ_PROC_FS_NAME, 0, ipq_get_info);
X ipq_sysctl_header = register_sysctl_table(ipq_root_table, 0);
X return status;
X }
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/netfilter/ip_tables.c linux/net/ipv4/netfilter/ip_tables.c
--- v2.4.9/linux/net/ipv4/netfilter/ip_tables.c Tue May 15 01:29:35 2001
+++ linux/net/ipv4/netfilter/ip_tables.c Fri Sep 14 14:04:08 2001
@@ -1730,9 +1730,15 @@
X }
X
X #ifdef CONFIG_PROC_FS
- if (!proc_net_create("ip_tables_names", 0, ipt_get_tables)) {
+ {
+ struct proc_dir_entry *proc;
+
+ proc = proc_net_create("ip_tables_names", 0, ipt_get_tables);
+ if (!proc) {
X nf_unregister_sockopt(&ipt_sockopts);
X return -ENOMEM;
+ }
+ proc->owner = THIS_MODULE;
X }
X #endif
X
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/netfilter/ipchains_core.c linux/net/ipv4/netfilter/ipchains_core.c
--- v2.4.9/linux/net/ipv4/netfilter/ipchains_core.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipv4/netfilter/ipchains_core.c Fri Sep 14 14:04:08 2001
@@ -74,6 +74,7 @@
X #include <linux/sched.h>
X #include <linux/string.h>
X #include <linux/errno.h>
+#include <linux/module.h>
X
X #include <linux/socket.h>
X #include <linux/sockios.h>
@@ -534,7 +535,7 @@
X }
X if (f->ipfw.fw_flg & IP_FW_F_NETLINK) {
X #if defined(CONFIG_NETLINK_DEV) || defined(CONFIG_NETLINK_DEV_MODULE)
- size_t len = min(unsigned int, f->ipfw.fw_outputsize, ntohs(ip->tot_len))
+ size_t len = min_t(unsigned int, f->ipfw.fw_outputsize, ntohs(ip->tot_len))
X + sizeof(__u32) + sizeof(skb->nfmark) + IFNAMSIZ;
X struct sk_buff *outskb=alloc_skb(len, GFP_ATOMIC);
X
@@ -1706,11 +1707,10 @@
X
X int ipfw_init_or_cleanup(int init)
X {
+ struct proc_dir_entry *proc;
X int ret = 0;
X unsigned long flags;
X
- FWC_WRITE_LOCK_IRQ(&ip_fw_lock, flags);
-
X if (!init) goto cleanup;
X
X #ifdef DEBUG_IP_FIREWALL_LOCKING
@@ -1727,17 +1727,24 @@
X if (ret < 0)
X goto cleanup_netlink;
X
- proc_net_create(IP_FW_PROC_CHAINS, S_IFREG | S_IRUSR | S_IWUSR, ip_chain_procinfo);
- proc_net_create(IP_FW_PROC_CHAIN_NAMES, S_IFREG | S_IRUSR | S_IWUSR, ip_chain_name_procinfo);
+ proc = proc_net_create(IP_FW_PROC_CHAINS, S_IFREG | S_IRUSR | S_IWUSR,
+ ip_chain_procinfo);
+ if (proc) proc->owner = THIS_MODULE;
+ proc = proc_net_create(IP_FW_PROC_CHAIN_NAMES,
+ S_IFREG | S_IRUSR | S_IWUSR,
+ ip_chain_name_procinfo);
+ if (proc) proc->owner = THIS_MODULE;
X
X IP_FW_INPUT_CHAIN = ip_init_chain(IP_FW_LABEL_INPUT, 1, FW_ACCEPT);
X IP_FW_FORWARD_CHAIN = ip_init_chain(IP_FW_LABEL_FORWARD, 1, FW_ACCEPT);
X IP_FW_OUTPUT_CHAIN = ip_init_chain(IP_FW_LABEL_OUTPUT, 1, FW_ACCEPT);
X
- FWC_WRITE_UNLOCK_IRQ(&ip_fw_lock, flags);
X return ret;
X
X cleanup:
+ unregister_firewall(PF_INET, &ipfw_ops);
+
+ FWC_WRITE_LOCK_IRQ(&ip_fw_lock, flags);
X while (ip_fw_chains) {
X struct ip_chain *next = ip_fw_chains->next;
X
@@ -1745,18 +1752,16 @@
X kfree(ip_fw_chains);
X ip_fw_chains = next;
X }
+ FWC_WRITE_UNLOCK_IRQ(&ip_fw_lock, flags);
X
X proc_net_remove(IP_FW_PROC_CHAINS);
X proc_net_remove(IP_FW_PROC_CHAIN_NAMES);
X
- unregister_firewall(PF_INET, &ipfw_ops);
-
X cleanup_netlink:
X #if defined(CONFIG_NETLINK_DEV) || defined(CONFIG_NETLINK_DEV_MODULE)
X sock_release(ipfwsk->socket);
X
X cleanup_nothing:
X #endif
- FWC_WRITE_UNLOCK_IRQ(&ip_fw_lock, flags);
X return ret;
X }
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/netfilter/ipfwadm_core.c linux/net/ipv4/netfilter/ipfwadm_core.c
--- v2.4.9/linux/net/ipv4/netfilter/ipfwadm_core.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipv4/netfilter/ipfwadm_core.c Thu Sep 20 14:12:56 2001
@@ -20,7 +20,7 @@
X * license in recognition of the original copyright.
X * -- Alan Cox.
X *
- * $Id: ipfwadm_core.c,v 1.8 2001/08/13 18:56:12 davem Exp $
+ * $Id: ipfwadm_core.c,v 1.9 2001/09/18 22:29:10 davem Exp $
X *
X * Ported from BSD to Linux,
X * Alan Cox 22/Nov/1994.
@@ -648,7 +648,7 @@
X struct sk_buff *skb=alloc_skb(128, GFP_ATOMIC);
X if(skb)
X {
- int len = min(unsigned int,
+ int len = min_t(unsigned int,
X 128, ntohs(ip->tot_len));
X
X skb_put(skb,len);
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/route.c linux/net/ipv4/route.c
--- v2.4.9/linux/net/ipv4/route.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipv4/route.c Thu Sep 20 14:12:56 2001
@@ -5,7 +5,7 @@
X *
X * ROUTE - implementation of the IP router.
X *
- * Version: $Id: route.c,v 1.98 2001/08/13 18:56:12 davem Exp $
+ * Version: $Id: route.c,v 1.99 2001/09/18 22:29:09 davem Exp $
X *
X * Authors: Ross Biro, <bi...@leland.Stanford.Edu>
X * Fred N. van Kempen, <wal...@uWalt.NL.Mugnet.ORG>
@@ -515,14 +515,14 @@
X equilibrium = ipv4_dst_ops.gc_thresh;
X goal = atomic_read(&ipv4_dst_ops.entries) - equilibrium;
X if (goal > 0) {
- equilibrium += min(unsigned int, goal / 2, rt_hash_mask + 1);
+ equilibrium += min_t(unsigned int, goal / 2, rt_hash_mask + 1);
X goal = atomic_read(&ipv4_dst_ops.entries) - equilibrium;
X }
X } else {
X /* We are in dangerous area. Try to reduce cache really
X * aggressively.
X */
- goal = max(unsigned int, goal / 2, rt_hash_mask + 1);
+ goal = max_t(unsigned int, goal / 2, rt_hash_mask + 1);
X equilibrium = atomic_read(&ipv4_dst_ops.entries) - goal;
X }
X
@@ -1207,7 +1207,7 @@
X if (rt->u.dst.pmtu > IP_MAX_MTU)
X rt->u.dst.pmtu = IP_MAX_MTU;
X if (rt->u.dst.advmss == 0)
- rt->u.dst.advmss = max(unsigned int, rt->u.dst.dev->mtu - 40,
+ rt->u.dst.advmss = max_t(unsigned int, rt->u.dst.dev->mtu - 40,
X ip_rt_min_advmss);
X if (rt->u.dst.advmss > 65535 - 40)
X rt->u.dst.advmss = 65535 - 40;
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/sysctl_net_ipv4.c linux/net/ipv4/sysctl_net_ipv4.c
--- v2.4.9/linux/net/ipv4/sysctl_net_ipv4.c Sun Mar 25 18:14:25 2001
+++ linux/net/ipv4/sysctl_net_ipv4.c Tue Aug 28 07:09:44 2001
@@ -1,7 +1,7 @@
X /*
X * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem.
X *
- * $Id: sysctl_net_ipv4.c,v 1.48 2001/02/23 01:39:05 davem Exp $
+ * $Id: sysctl_net_ipv4.c,v 1.49 2001/08/22 20:38:41 davem Exp $
X *
X * Begun April 1, 1996, Mike Shaver.
X * Added /proc/sys/net/ipv4 directory entry (empty =) ). [MS]
@@ -32,10 +32,8 @@
X extern int sysctl_ip_dynaddr;
X
X /* From icmp.c */
-extern int sysctl_icmp_destunreach_time;
-extern int sysctl_icmp_timeexceed_time;
-extern int sysctl_icmp_paramprob_time;
-extern int sysctl_icmp_echoreply_time;
+extern int sysctl_icmp_ratelimit;
+extern int sysctl_icmp_ratemask;
X
X /* From igmp.c */
X extern int sysctl_igmp_max_memberships;
@@ -178,14 +176,6 @@
X {NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES, "icmp_ignore_bogus_error_responses",
X &sysctl_icmp_ignore_bogus_error_responses, sizeof(int), 0644, NULL,
X &proc_dointvec},
- {NET_IPV4_ICMP_DESTUNREACH_RATE, "icmp_destunreach_rate",
- &sysctl_icmp_destunreach_time, sizeof(int), 0644, NULL, &proc_dointvec},
- {NET_IPV4_ICMP_TIMEEXCEED_RATE, "icmp_timeexceed_rate",
- &sysctl_icmp_timeexceed_time, sizeof(int), 0644, NULL, &proc_dointvec},
- {NET_IPV4_ICMP_PARAMPROB_RATE, "icmp_paramprob_rate",
- &sysctl_icmp_paramprob_time, sizeof(int), 0644, NULL, &proc_dointvec},
- {NET_IPV4_ICMP_ECHOREPLY_RATE, "icmp_echoreply_rate",
- &sysctl_icmp_echoreply_time, sizeof(int), 0644, NULL, &proc_dointvec},
X {NET_IPV4_ROUTE, "route", NULL, 0, 0555, ipv4_route_table},
X #ifdef CONFIG_IP_MULTICAST
X {NET_IPV4_IGMP_MAX_MEMBERSHIPS, "igmp_max_memberships",
@@ -227,6 +217,10 @@
X &sysctl_tcp_app_win, sizeof(int), 0644, NULL, &proc_dointvec},
X {NET_TCP_ADV_WIN_SCALE, "tcp_adv_win_scale",
X &sysctl_tcp_adv_win_scale, sizeof(int), 0644, NULL, &proc_dointvec},
+ {NET_IPV4_ICMP_RATELIMIT, "icmp_ratelimit",
+ &sysctl_icmp_ratelimit, sizeof(int), 0644, NULL, &proc_dointvec},
+ {NET_IPV4_ICMP_RATEMASK, "icmp_ratemask",
+ &sysctl_icmp_ratemask, sizeof(int), 0644, NULL, &proc_dointvec},
X {0}
X };
X
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/tcp.c linux/net/ipv4/tcp.c
--- v2.4.9/linux/net/ipv4/tcp.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipv4/tcp.c Thu Sep 20 14:12:56 2001
@@ -5,7 +5,7 @@
X *
X * Implementation of the Transmission Control Protocol(TCP).
X *
- * Version: $Id: tcp.c,v 1.208 2001/08/13 18:56:12 davem Exp $
+ * Version: $Id: tcp.c,v 1.211 2001/09/20 00:35:35 davem Exp $
X *
X * Authors: Ross Biro, <bi...@leland.Stanford.Edu>
X * Fred N. van Kempen, <wal...@uWalt.NL.Mugnet.ORG>
@@ -852,7 +852,7 @@
X
X page = pages[poffset/PAGE_SIZE];
X offset = poffset % PAGE_SIZE;
- size = min(unsigned int, psize, PAGE_SIZE-offset);
+ size = min_t(unsigned int, psize, PAGE_SIZE-offset);
X
X if (tp->send_head==NULL || (copy = mss_now - skb->len) <= 0) {
X new_segment:
@@ -1236,7 +1236,7 @@
X msg->msg_flags|=MSG_OOB;
X
X if(len>0) {
- if (!(flags & MSG_PEEK) && !(flags & MSG_TRUNC))
+ if (!(flags & MSG_TRUNC))
X err = memcpy_toiovec(msg->msg_iov, &c, 1);
X len = 1;
X } else
@@ -2326,7 +2326,7 @@
X if(get_user(len,optlen))
X return -EFAULT;
X
- len = min(unsigned int, len, sizeof(int));
+ len = min_t(unsigned int, len, sizeof(int));
X
X if(len < 0)
X return -EINVAL;
@@ -2361,7 +2361,7 @@
X val = (val ? : sysctl_tcp_fin_timeout)/HZ;
X break;
X case TCP_DEFER_ACCEPT:
- val = tp->defer_accept == 0 ? 0 : (TCP_TIMEOUT_INIT<<(tp->defer_accept-1));
+ val = tp->defer_accept == 0 ? 0 : ((TCP_TIMEOUT_INIT/HZ)<<(tp->defer_accept-1));
X break;
X case TCP_WINDOW_CLAMP:
X val = tp->window_clamp;
@@ -2421,7 +2421,7 @@
X info.tcpi_advmss = tp->advmss;
X info.tcpi_reordering = tp->reordering;
X
- len = min(unsigned int, len, sizeof(info));
+ len = min_t(unsigned int, len, sizeof(info));
X if(put_user(len, optlen))
X return -EFAULT;
X if(copy_to_user(optval, &info,len))
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/tcp_input.c linux/net/ipv4/tcp_input.c
--- v2.4.9/linux/net/ipv4/tcp_input.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipv4/tcp_input.c Thu Sep 20 14:12:56 2001
@@ -5,7 +5,7 @@
X *
X * Implementation of the Transmission Control Protocol(TCP).
X *
- * Version: $Id: tcp_input.c,v 1.235 2001/08/13 18:56:12 davem Exp $
+ * Version: $Id: tcp_input.c,v 1.236 2001/09/18 22:29:09 davem Exp $
X *
X * Authors: Ross Biro, <bi...@leland.Stanford.Edu>
X * Fred N. van Kempen, <wal...@uWalt.NL.Mugnet.ORG>
@@ -168,7 +168,7 @@
X if (quickacks==0)
X quickacks=2;
X if (quickacks > tp->ack.quick)
- tp->ack.quick = min(unsigned int, quickacks, TCP_MAX_QUICKACKS);
+ tp->ack.quick = min_t(unsigned int, quickacks, TCP_MAX_QUICKACKS);
X }
X
X void tcp_enter_quickack_mode(struct tcp_opt *tp)
@@ -198,7 +198,7 @@
X int sndmem = tp->mss_clamp+MAX_TCP_HEADER+16+sizeof(struct sk_buff);
X
X if (sk->sndbuf < 3*sndmem)
- sk->sndbuf = min(int, 3*sndmem, sysctl_tcp_wmem[2]);
+ sk->sndbuf = min_t(int, 3*sndmem, sysctl_tcp_wmem[2]);
X }
X
X /* 2. Tuning advertised window (window_clamp, rcv_ssthresh)
@@ -262,7 +262,7 @@
X incr = __tcp_grow_window(sk, tp, skb);
X
X if (incr) {
- tp->rcv_ssthresh = min(u32, tp->rcv_ssthresh + incr, tp->window_clamp);
+ tp->rcv_ssthresh = min_t(u32, tp->rcv_ssthresh + incr, tp->window_clamp);
X tp->ack.quick |= 1;
X }
X }
@@ -282,7 +282,7 @@
X while (tcp_win_from_space(rcvmem) < tp->advmss)
X rcvmem += 128;
X if (sk->rcvbuf < 4*rcvmem)
- sk->rcvbuf = min(int, 4*rcvmem, sysctl_tcp_rmem[2]);
+ sk->rcvbuf = min_t(int, 4*rcvmem, sysctl_tcp_rmem[2]);
X }
X
X /* 4. Try to fixup all. It is made iimediately after connection enters
@@ -304,16 +304,16 @@
X tp->window_clamp = maxwin;
X
X if (sysctl_tcp_app_win && maxwin>4*tp->advmss)
- tp->window_clamp = max(u32, maxwin-(maxwin>>sysctl_tcp_app_win), 4*tp->advmss);
+ tp->window_clamp = max_t(u32, maxwin-(maxwin>>sysctl_tcp_app_win), 4*tp->advmss);
X }
X
X /* Force reservation of one segment. */
X if (sysctl_tcp_app_win &&
X tp->window_clamp > 2*tp->advmss &&
X tp->window_clamp + tp->advmss > maxwin)
- tp->window_clamp = max(u32, 2*tp->advmss, maxwin-tp->advmss);
+ tp->window_clamp = max_t(u32, 2*tp->advmss, maxwin-tp->advmss);
X
- tp->rcv_ssthresh = min(u32, tp->rcv_ssthresh, tp->window_clamp);
+ tp->rcv_ssthresh = min_t(u32, tp->rcv_ssthresh, tp->window_clamp);
X tp->snd_cwnd_stamp = tcp_time_stamp;
X }
X
@@ -338,7 +338,7 @@
X !(sk->userlocks&SOCK_RCVBUF_LOCK) &&
X !tcp_memory_pressure &&
X atomic_read(&tcp_memory_allocated) < sysctl_tcp_mem[0])
- sk->rcvbuf = min(int, atomic_read(&sk->rmem_alloc), sysctl_tcp_rmem[2]);
+ sk->rcvbuf = min_t(int, atomic_read(&sk->rmem_alloc), sysctl_tcp_rmem[2]);
X }
X if (atomic_read(&sk->rmem_alloc) > sk->rcvbuf) {
X app_win += ofo_win;
@@ -346,11 +346,11 @@
X app_win >>= 1;
X if (app_win > tp->ack.rcv_mss)
X app_win -= tp->ack.rcv_mss;
- app_win = max(unsigned int, app_win, 2*tp->advmss);
+ app_win = max_t(unsigned int, app_win, 2*tp->advmss);
X
X if (!ofo_win)
- tp->window_clamp = min(u32, tp->window_clamp, app_win);
- tp->rcv_ssthresh = min(u32, tp->window_clamp, 2*tp->advmss);
+ tp->window_clamp = min_t(u32, tp->window_clamp, app_win);
+ tp->rcv_ssthresh = min_t(u32, tp->window_clamp, 2*tp->advmss);
X }
X }
X
@@ -472,7 +472,7 @@
X /* no previous measure. */
X tp->srtt = m<<3; /* take the measured time to be rtt */
X tp->mdev = m<<2; /* make sure rto = 3*rtt */
- tp->mdev_max = tp->rttvar = max(u32, tp->mdev, TCP_RTO_MIN);
+ tp->mdev_max = tp->rttvar = max_t(u32, tp->mdev, TCP_RTO_MIN);
X tp->rtt_seq = tp->snd_nxt;
X }
X }
@@ -575,7 +575,7 @@
X tp->ca_state == TCP_CA_Open) {
X /* Cong. avoidance phase, cwnd is reliable. */
X if (!(dst->mxlock&(1<<RTAX_SSTHRESH)))
- dst->ssthresh = max(u32, tp->snd_cwnd>>1, tp->snd_ssthresh);
+ dst->ssthresh = max_t(u32, tp->snd_cwnd>>1, tp->snd_ssthresh);
X if (!(dst->mxlock&(1<<RTAX_CWND)))
X dst->cwnd = (dst->cwnd + tp->snd_cwnd)>>1;
X } else {
@@ -617,7 +617,7 @@
X else if (cwnd > tp->snd_ssthresh)
X cwnd = tp->snd_ssthresh;
X
- return min(u32, cwnd, tp->snd_cwnd_clamp);
+ return min_t(u32, cwnd, tp->snd_cwnd_clamp);
X }
X
X /* Initialize metrics on socket. */
@@ -668,7 +668,7 @@
X tp->srtt = dst->rtt;
X if (dst->rttvar > tp->mdev) {
X tp->mdev = dst->rttvar;
- tp->mdev_max = tp->rttvar = max(u32, tp->mdev, TCP_RTO_MIN);
+ tp->mdev_max = tp->rttvar = max_t(u32, tp->mdev, TCP_RTO_MIN);
X }
X tcp_set_rto(tp);
X tcp_bound_rto(tp);
@@ -693,7 +693,7 @@
X static void tcp_update_reordering(struct tcp_opt *tp, int metric, int ts)
X {
X if (metric > tp->reordering) {
- tp->reordering = min(unsigned int, TCP_MAX_REORDERING, metric);
+ tp->reordering = min_t(unsigned int, TCP_MAX_REORDERING, metric);
X
X /* This exciting event is worth to be remembered. 8) */
X if (ts)
@@ -848,12 +848,12 @@
X if (sacked&TCPCB_RETRANS) {
X if ((dup_sack && in_sack) &&
X (sacked&TCPCB_SACKED_ACKED))
- reord = min(int, fack_count, reord);
+ reord = min_t(int, fack_count, reord);
X } else {
X /* If it was in a hole, we detected reordering. */
X if (fack_count < prior_fackets &&
X !(sacked&TCPCB_SACKED_ACKED))
- reord = min(int, fack_count, reord);
+ reord = min_t(int, fack_count, reord);
X }
X
X /* Nothing to do; acked frame is about to be dropped. */
@@ -885,7 +885,7 @@
X */
X if (!(sacked & TCPCB_RETRANS) &&
X fack_count < prior_fackets)
- reord = min(int, fack_count, reord);
+ reord = min_t(int, fack_count, reord);
X
X if (sacked & TCPCB_LOST) {
X TCP_SKB_CB(skb)->sacked &= ~TCPCB_LOST;
@@ -901,7 +901,7 @@
X tp->fackets_out = fack_count;
X } else {
X if (dup_sack && (sacked&TCPCB_RETRANS))
- reord = min(int, fack_count, reord);
+ reord = min_t(int, fack_count, reord);
X }
X
X /* D-SACK. We can detect redundant retransmission
@@ -1019,7 +1019,7 @@
X }
X tcp_sync_left_out(tp);
X
- tp->reordering = min(unsigned int, tp->reordering, sysctl_tcp_reordering);
+ tp->reordering = min_t(unsigned int, tp->reordering, sysctl_tcp_reordering);
X tp->ca_state = TCP_CA_Loss;
X tp->high_seq = tp->snd_nxt;
X TCP_ECN_queue_cwr(tp);
@@ -1177,7 +1177,7 @@
X * recovery more?
X */
X if (tp->packets_out <= tp->reordering &&
- tp->sacked_out >= max(u32, tp->packets_out/2, sysctl_tcp_reordering) &&
+ tp->sacked_out >= max_t(u32, tp->packets_out/2, sysctl_tcp_reordering) &&
X !tcp_may_send_now(sk, tp)) {
X /* We have nothing to send. This connection is limited
X * either by receiver window or by application.
@@ -1194,8 +1194,8 @@
X */
X static void tcp_check_reno_reordering(struct tcp_opt *tp, int addend)
X {
- u32 holes = min(unsigned int,
- max(unsigned int, tp->lost_out, 1),
+ u32 holes = min_t(unsigned int,
+ max_t(unsigned int, tp->lost_out, 1),
X tp->packets_out);
X
X if (tp->sacked_out + holes > tp->packets_out) {
@@ -1291,7 +1291,7 @@
X */
X static __inline__ void tcp_moderate_cwnd(struct tcp_opt *tp)
X {
- tp->snd_cwnd = min(u32, tp->snd_cwnd,
+ tp->snd_cwnd = min_t(u32, tp->snd_cwnd,
X tcp_packets_in_flight(tp)+tcp_max_burst(tp));
X tp->snd_cwnd_stamp = tcp_time_stamp;
X }
@@ -1308,7 +1308,7 @@
X if (decr && tp->snd_cwnd > tp->snd_ssthresh/2)
X tp->snd_cwnd -= decr;
X
- tp->snd_cwnd = min(u32, tp->snd_cwnd, tcp_packets_in_flight(tp)+1);
+ tp->snd_cwnd = min_t(u32, tp->snd_cwnd, tcp_packets_in_flight(tp)+1);
X tp->snd_cwnd_stamp = tcp_time_stamp;
X }
X
@@ -1340,7 +1340,7 @@
X static void tcp_undo_cwr(struct tcp_opt *tp, int undo)
X {
X if (tp->prior_ssthresh) {
- tp->snd_cwnd = max(unsigned int,
+ tp->snd_cwnd = max_t(unsigned int,
X tp->snd_cwnd, tp->snd_ssthresh<<1);
X
X if (undo && tp->prior_ssthresh > tp->snd_ssthresh) {
@@ -1348,7 +1348,7 @@
X TCP_ECN_withdraw_cwr(tp);
X }
X } else {
- tp->snd_cwnd = max(unsigned int, tp->snd_cwnd, tp->snd_ssthresh);
+ tp->snd_cwnd = max_t(unsigned int, tp->snd_cwnd, tp->snd_ssthresh);
X }
X tcp_moderate_cwnd(tp);
X tp->snd_cwnd_stamp = tcp_time_stamp;
@@ -1450,7 +1450,7 @@
X
X static __inline__ void tcp_complete_cwr(struct tcp_opt *tp)
X {
- tp->snd_cwnd = min(u32, tp->snd_cwnd, tp->snd_ssthresh);
+ tp->snd_cwnd = min_t(u32, tp->snd_cwnd, tp->snd_ssthresh);
X tp->snd_cwnd_stamp = tcp_time_stamp;
X }
X
@@ -1836,7 +1836,7 @@
X */
X } else {
X tcp_reset_xmit_timer(sk, TCP_TIME_PROBE0,
- min(u32, tp->rto << tp->backoff, TCP_RTO_MAX));
+ min_t(u32, tp->rto << tp->backoff, TCP_RTO_MAX));
X }
X }
X
@@ -2323,7 +2323,7 @@
X tp->dsack = 1;
X tp->duplicate_sack[0].start_seq = seq;
X tp->duplicate_sack[0].end_seq = end_seq;
- tp->eff_sacks = min(unsigned int, tp->num_sacks+1, 4-tp->tstamp_ok);
SHAR_EOF
true || echo 'restore of patch-2.4.10 failed'
fi
echo 'End of part 195'
echo 'File patch-2.4.10 is continued in part 196'
echo "196" > _shar_seq_.tmp
exit 0

Thomas Kobienia

unread,
Sep 24, 2001, 8:00:59 PM9/24/01
to
Archive-name: v2.4/patch-2.4.10/part196

#!/bin/sh -x
# this is part 196 of a 197 - part archive


# do not concatenate these parts, unpack them in order with /bin/sh
# file patch-2.4.10 continued
if test ! -r _shar_seq_.tmp; then
echo 'Please unpack part 1 first!'
exit 1
fi
(read Scheck

if test "$Scheck" != 196; then


echo "Please unpack part $Scheck next!"
exit 1
else
exit 0
fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
echo 'x - still skipping patch-2.4.10'
else
echo 'x - continuing with patch-2.4.10'
sed 's/^X//' << 'SHAR_EOF' >> 'patch-2.4.10' &&

+ tp->eff_sacks = min_t(unsigned int, tp->num_sacks+1, 4-tp->tstamp_ok);
X }
X }
X
@@ -2376,7 +2376,7 @@
X * Decrease num_sacks.
X */
X tp->num_sacks--;
- tp->eff_sacks = min(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
+ tp->eff_sacks = min_t(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
X for(i=this_sack; i < tp->num_sacks; i++)
X sp[i] = sp[i+1];
X continue;
@@ -2438,7 +2438,7 @@
X sp->start_seq = seq;
X sp->end_seq = end_seq;
X tp->num_sacks++;
- tp->eff_sacks = min(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
+ tp->eff_sacks = min_t(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
X }
X
X /* RCV.NXT advances, some SACKs should be eaten. */
@@ -2475,7 +2475,7 @@
X }
X if (num_sacks != tp->num_sacks) {
X tp->num_sacks = num_sacks;
- tp->eff_sacks = min(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
+ tp->eff_sacks = min_t(unsigned int, tp->num_sacks+tp->dsack, 4-tp->tstamp_ok);
X }
X }
X
@@ -2541,7 +2541,7 @@
X
X if (tp->dsack) {
X tp->dsack = 0;
- tp->eff_sacks = min(unsigned int, tp->num_sacks, 4-tp->tstamp_ok);
+ tp->eff_sacks = min_t(unsigned int, tp->num_sacks, 4-tp->tstamp_ok);
X }
X
X /* Queue data for delivery to the user.
@@ -2558,7 +2558,7 @@
X tp->ucopy.len &&
X sk->lock.users &&
X !tp->urg_data) {
- int chunk = min(unsigned int, skb->len, tp->ucopy.len);
+ int chunk = min_t(unsigned int, skb->len, tp->ucopy.len);
X
X __set_current_state(TASK_RUNNING);
X
@@ -2807,7 +2807,7 @@
X
X if (offset < 0) BUG();
X if (size > 0) {
- size = min(int, copy, size);
+ size = min_t(int, copy, size);
X if (skb_copy_bits(skb, offset, skb_put(nskb, size), size))
X BUG();
X TCP_SKB_CB(nskb)->end_seq += size;
@@ -2886,7 +2886,7 @@
X if (atomic_read(&sk->rmem_alloc) >= sk->rcvbuf)
X tcp_clamp_window(sk, tp);
X else if (tcp_memory_pressure)
- tp->rcv_ssthresh = min(u32, tp->rcv_ssthresh, 4*tp->advmss);
+ tp->rcv_ssthresh = min_t(u32, tp->rcv_ssthresh, 4*tp->advmss);
X
X tcp_collapse_ofo_queue(sk);
X tcp_collapse(sk, sk->receive_queue.next,
@@ -2941,7 +2941,7 @@
X if (tp->ca_state == TCP_CA_Open &&
X sk->socket && !test_bit(SOCK_NOSPACE, &sk->socket->flags)) {
X /* Limited by application or receiver window. */
- u32 win_used = max(u32, tp->snd_cwnd_used, 2);
+ u32 win_used = max_t(u32, tp->snd_cwnd_used, 2);
X if (win_used < tp->snd_cwnd) {
X tp->snd_ssthresh = tcp_current_ssthresh(tp);
X tp->snd_cwnd = (tp->snd_cwnd+win_used)>>1;
@@ -2967,10 +2967,10 @@
X int sndmem, demanded;
X
X sndmem = tp->mss_clamp+MAX_TCP_HEADER+16+sizeof(struct sk_buff);
- demanded = max(unsigned int, tp->snd_cwnd, tp->reordering+1);
+ demanded = max_t(unsigned int, tp->snd_cwnd, tp->reordering+1);
X sndmem *= 2*demanded;
X if (sndmem > sk->sndbuf)
- sk->sndbuf = min(int, sndmem, sysctl_tcp_wmem[2]);
+ sk->sndbuf = min_t(int, sndmem, sysctl_tcp_wmem[2]);


X tp->snd_cwnd_stamp = tcp_time_stamp;
X }
X

@@ -3520,7 +3520,7 @@
X
X if (tp->wscale_ok == 0) {
X tp->snd_wscale = tp->rcv_wscale = 0;
- tp->window_clamp = min(u32, tp->window_clamp, 65535);
+ tp->window_clamp = min_t(u32, tp->window_clamp, 65535);
X }
X
X if (tp->saw_tstamp) {
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/tcp_ipv4.c linux/net/ipv4/tcp_ipv4.c
--- v2.4.9/linux/net/ipv4/tcp_ipv4.c Wed Apr 25 14:57:39 2001
+++ linux/net/ipv4/tcp_ipv4.c Fri Sep 7 11:01:21 2001


@@ -5,7 +5,7 @@
X *

X * Implementation of the Transmission Control Protocol(TCP).
X *

- * Version: $Id: tcp_ipv4.c,v 1.229 2001/04/20 20:46:19 davem Exp $
+ * Version: $Id: tcp_ipv4.c,v 1.230 2001/09/01 00:31:50 davem Exp $
X *
X * IPv4 specific functions
X *
@@ -1505,7 +1505,7 @@
X skb->nh.iph->daddr,skb->csum))
X return 0;
X
- NETDEBUG(printk(KERN_DEBUG "hw tcp v4 csum failed\n"));
+ NETDEBUG(if (net_ratelimit()) printk(KERN_DEBUG "hw tcp v4 csum failed\n"));
X skb->ip_summed = CHECKSUM_NONE;
X }
X if (skb->len <= 76) {
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/tcp_minisocks.c linux/net/ipv4/tcp_minisocks.c
--- v2.4.9/linux/net/ipv4/tcp_minisocks.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipv4/tcp_minisocks.c Thu Sep 20 14:12:56 2001


@@ -5,7 +5,7 @@
X *
X * Implementation of the Transmission Control Protocol(TCP).
X *

- * Version: $Id: tcp_minisocks.c,v 1.12 2001/08/13 18:56:13 davem Exp $
+ * Version: $Id: tcp_minisocks.c,v 1.13 2001/09/18 22:29:10 davem Exp $
X *


X * Authors: Ross Biro, <bi...@leland.Stanford.Edu>
X * Fred N. van Kempen, <wal...@uWalt.NL.Mugnet.ORG>

@@ -766,7 +766,7 @@
X newtp->rcv_wscale = req->rcv_wscale;
X } else {
X newtp->snd_wscale = newtp->rcv_wscale = 0;
- newtp->window_clamp = min(u32, newtp->window_clamp, 65535);
+ newtp->window_clamp = min_t(u32, newtp->window_clamp, 65535);
X }
X newtp->snd_wnd = ntohs(skb->h.th->window) << newtp->snd_wscale;
X newtp->max_window = newtp->snd_wnd;
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/tcp_output.c linux/net/ipv4/tcp_output.c
--- v2.4.9/linux/net/ipv4/tcp_output.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipv4/tcp_output.c Thu Sep 20 14:12:56 2001


@@ -5,7 +5,7 @@
X *
X * Implementation of the Transmission Control Protocol(TCP).
X *

- * Version: $Id: tcp_output.c,v 1.140 2001/08/13 18:56:12 davem Exp $
+ * Version: $Id: tcp_output.c,v 1.141 2001/09/18 22:29:10 davem Exp $
X *


X * Authors: Ross Biro, <bi...@leland.Stanford.Edu>
X * Fred N. van Kempen, <wal...@uWalt.NL.Mugnet.ORG>

@@ -105,11 +105,11 @@
X u32 cwnd = tp->snd_cwnd;
X
X tp->snd_ssthresh = tcp_current_ssthresh(tp);
- restart_cwnd = min(u32, restart_cwnd, cwnd);
+ restart_cwnd = min_t(u32, restart_cwnd, cwnd);
X
X while ((delta -= tp->rto) > 0 && cwnd > restart_cwnd)
X cwnd >>= 1;
- tp->snd_cwnd = max(u32, cwnd, restart_cwnd);
+ tp->snd_cwnd = max_t(u32, cwnd, restart_cwnd);


X tp->snd_cwnd_stamp = tcp_time_stamp;

X tp->snd_cwnd_used = 0;
X }
@@ -526,7 +526,7 @@
X
X /* Bound mss with half of window */
X if (tp->max_window && mss_now > (tp->max_window>>1))
- mss_now = max(u32, (tp->max_window>>1), 68 - tp->tcp_header_len);
+ mss_now = max_t(u32, (tp->max_window>>1), 68 - tp->tcp_header_len);
X
X /* And store cached results */
X tp->pmtu_cookie = pmtu;
@@ -651,7 +651,7 @@
X */
X int mss = tp->ack.rcv_mss;
X int free_space = tcp_space(sk);
- int full_space = min(unsigned int, tp->window_clamp, tcp_full_space(sk));
+ int full_space = min_t(unsigned int, tp->window_clamp, tcp_full_space(sk));
X int window;
X
X if (mss > full_space)
@@ -661,7 +661,7 @@
X tp->ack.quick = 0;
X
X if (tcp_memory_pressure)
- tp->rcv_ssthresh = min(u32, tp->rcv_ssthresh, 4*tp->advmss);
+ tp->rcv_ssthresh = min_t(u32, tp->rcv_ssthresh, 4*tp->advmss);
X
X if (free_space < mss)
X return 0;
@@ -817,7 +817,7 @@
X /* Do not sent more than we queued. 1/4 is reserved for possible
X * copying overhead: frgagmentation, tunneling, mangling etc.
X */
- if (atomic_read(&sk->wmem_alloc) > min(int, sk->wmem_queued+(sk->wmem_queued>>2),sk->sndbuf))
+ if (atomic_read(&sk->wmem_alloc) > min_t(int, sk->wmem_queued+(sk->wmem_queued>>2),sk->sndbuf))
X return -EAGAIN;
X
X /* If receiver has shrunk his window, and skb is out of
@@ -1264,13 +1264,13 @@
X * directly.
X */
X if (tp->srtt) {
- int rtt = max(unsigned int, tp->srtt>>3, TCP_DELACK_MIN);
+ int rtt = max_t(unsigned int, tp->srtt>>3, TCP_DELACK_MIN);
X
X if (rtt < max_ato)
X max_ato = rtt;
X }
X
- ato = min(int, ato, max_ato);
+ ato = min_t(int, ato, max_ato);
X }
X
X /* Stay within the limit we were given */
@@ -1386,7 +1386,7 @@
X */
X if (seg_size < TCP_SKB_CB(skb)->end_seq - TCP_SKB_CB(skb)->seq ||
X skb->len > mss) {
- seg_size = min(int, seg_size, mss);
+ seg_size = min_t(int, seg_size, mss);
X TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_PSH;
X if (tcp_fragment(sk, skb, seg_size))
X return -1;
@@ -1429,7 +1429,7 @@
X tp->backoff++;
X tp->probes_out++;
X tcp_reset_xmit_timer (sk, TCP_TIME_PROBE0,

- min(u32, tp->rto << tp->backoff, TCP_RTO_MAX));
+ min_t(u32, tp->rto << tp->backoff, TCP_RTO_MAX));

X } else {
X /* If packet was not sent due to local congestion,
X * do not backoff and do not remember probes_out.
@@ -1440,6 +1440,6 @@
X if (!tp->probes_out)
X tp->probes_out=1;
X tcp_reset_xmit_timer (sk, TCP_TIME_PROBE0,
- min(unsigned int, tp->rto << tp->backoff, TCP_RESOURCE_PROBE_INTERVAL));
+ min_t(unsigned int, tp->rto << tp->backoff, TCP_RESOURCE_PROBE_INTERVAL));
X }
X }
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/tcp_timer.c linux/net/ipv4/tcp_timer.c
--- v2.4.9/linux/net/ipv4/tcp_timer.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipv4/tcp_timer.c Thu Sep 20 14:12:56 2001


@@ -5,7 +5,7 @@
X *
X * Implementation of the Transmission Control Protocol(TCP).
X *

- * Version: $Id: tcp_timer.c,v 1.85 2001/08/13 18:56:12 davem Exp $
+ * Version: $Id: tcp_timer.c,v 1.86 2001/09/18 22:29:10 davem Exp $
X *


X * Authors: Ross Biro, <bi...@leland.Stanford.Edu>
X * Fred N. van Kempen, <wal...@uWalt.NL.Mugnet.ORG>

@@ -248,7 +248,7 @@
X if (tcp_ack_scheduled(tp)) {
X if (!tp->ack.pingpong) {
X /* Delayed ACK missed: inflate ATO. */
- tp->ack.ato = min(u32, tp->ack.ato << 1, tp->rto);
+ tp->ack.ato = min_t(u32, tp->ack.ato << 1, tp->rto);
X } else {
X /* Delayed ACK missed: leave pingpong mode and
X * deflate ATO.
@@ -381,7 +381,7 @@
X if (!tp->retransmits)
X tp->retransmits=1;
X tcp_reset_xmit_timer(sk, TCP_TIME_RETRANS,
- min(u32, tp->rto, TCP_RESOURCE_PROBE_INTERVAL));
+ min_t(u32, tp->rto, TCP_RESOURCE_PROBE_INTERVAL));
X goto out;
X }
X
@@ -404,7 +404,7 @@
X tp->retransmits++;
X
X out_reset_timer:
- tp->rto = min(u32, tp->rto << 1, TCP_RTO_MAX);
+ tp->rto = min_t(u32, tp->rto << 1, TCP_RTO_MAX);
X tcp_reset_xmit_timer(sk, TCP_TIME_RETRANS, tp->rto);
X if (tp->retransmits > sysctl_tcp_retries1)
X __sk_dst_reset(sk);
@@ -517,7 +517,7 @@
X
X if (req->retrans++ == 0)
X lopt->qlen_young--;
- timeo = min(unsigned long,
+ timeo = min_t(unsigned long,
X (TCP_TIMEOUT_INIT << req->retrans),
X TCP_RTO_MAX);
X req->expires = now + timeo;
diff -u --recursive --new-file v2.4.9/linux/net/ipv4/udp.c linux/net/ipv4/udp.c
--- v2.4.9/linux/net/ipv4/udp.c Thu Apr 12 12:11:39 2001
+++ linux/net/ipv4/udp.c Fri Sep 7 11:01:21 2001


@@ -5,7 +5,7 @@
X *

X * The User Datagram Protocol (UDP).
X *
- * Version: $Id: udp.c,v 1.98 2001/03/06 21:15:10 davem Exp $
+ * Version: $Id: udp.c,v 1.99 2001/09/01 00:31:50 davem Exp $


X *
X * Authors: Ross Biro, <bi...@leland.Stanford.Edu>
X * Fred N. van Kempen, <wal...@uWalt.NL.Mugnet.ORG>

@@ -856,7 +856,7 @@
X skb->ip_summed = CHECKSUM_UNNECESSARY;
X if (!udp_check(uh, ulen, saddr, daddr, skb->csum))
X return 0;
- NETDEBUG(printk(KERN_DEBUG "udp v4 hw csum failure.\n"));
+ NETDEBUG(if (net_ratelimit()) printk(KERN_DEBUG "udp v4 hw csum failure.\n"));
X skb->ip_summed = CHECKSUM_NONE;
X }
X if (skb->ip_summed != CHECKSUM_UNNECESSARY)
@@ -925,7 +925,7 @@
X return(0);
X
X short_packet:
- NETDEBUG(printk(KERN_DEBUG "UDP: short packet: %d/%d\n", ulen, len));
+ NETDEBUG(if (net_ratelimit()) printk(KERN_DEBUG "UDP: short packet: %d/%d\n", ulen, len));
X UDP_INC_STATS_BH(UdpInErrors);
X kfree_skb(skb);
X return(0);
@@ -935,7 +935,8 @@
X * RFC1122: OK. Discards the bad packet silently (as far as
X * the network is concerned, anyway) as per 4.1.3.4 (MUST).
X */
- NETDEBUG(printk(KERN_DEBUG "UDP: bad checksum. From %d.%d.%d.%d:%d to %d.%d.%d.%d:%d ulen %d\n",
+ NETDEBUG(if (net_ratelimit())
+ printk(KERN_DEBUG "UDP: bad checksum. From %d.%d.%d.%d:%d to %d.%d.%d.%d:%d ulen %d\n",
X NIPQUAD(saddr),
X ntohs(uh->source),
X NIPQUAD(daddr),
diff -u --recursive --new-file v2.4.9/linux/net/ipv6/addrconf.c linux/net/ipv6/addrconf.c
--- v2.4.9/linux/net/ipv6/addrconf.c Sun Aug 12 13:28:01 2001
+++ linux/net/ipv6/addrconf.c Fri Sep 7 11:01:21 2001
@@ -6,7 +6,7 @@
X * Pedro Roque <ro...@di.fc.ul.pt>
X * Alexey Kuznetsov <kuz...@ms2.inr.ac.ru>
X *
- * $Id: addrconf.c,v 1.67 2001/08/03 09:32:17 davem Exp $
+ * $Id: addrconf.c,v 1.68 2001/09/01 00:31:50 davem Exp $


X *
X * This program is free software; you can redistribute it and/or
X * modify it under the terms of the GNU General Public License

@@ -628,7 +628,8 @@
X
X void addrconf_dad_failure(struct inet6_ifaddr *ifp)
X {
- printk(KERN_INFO "%s: duplicate address detected!\n", ifp->idev->dev->name);
+ if (net_ratelimit())
+ printk(KERN_INFO "%s: duplicate address detected!\n", ifp->idev->dev->name);
X if (ifp->flags&IFA_F_PERMANENT) {
X spin_lock_bh(&ifp->lock);
X addrconf_del_timer(ifp);
@@ -818,14 +819,16 @@
X prefered_lft = ntohl(pinfo->prefered);
X
X if (prefered_lft > valid_lft) {
- printk(KERN_WARNING "addrconf: prefix option has invalid lifetime\n");
+ if (net_ratelimit())
+ printk(KERN_WARNING "addrconf: prefix option has invalid lifetime\n");
X return;
X }
X
X in6_dev = in6_dev_get(dev);
X
X if (in6_dev == NULL) {
- printk(KERN_DEBUG "addrconf: device %s not configured\n", dev->name);
+ if (net_ratelimit())
+ printk(KERN_DEBUG "addrconf: device %s not configured\n", dev->name);
X return;
X }
X
@@ -881,7 +884,9 @@
X }
X goto ok;
X }
- printk(KERN_DEBUG "IPv6 addrconf: prefix with wrong length %d\n", pinfo->prefix_len);
+ if (net_ratelimit())
+ printk(KERN_DEBUG "IPv6 addrconf: prefix with wrong length %d\n",
+ pinfo->prefix_len);
X in6_dev_put(in6_dev);
X return;
X
diff -u --recursive --new-file v2.4.9/linux/net/ipv6/datagram.c linux/net/ipv6/datagram.c
--- v2.4.9/linux/net/ipv6/datagram.c Thu Apr 12 12:11:39 2001
+++ linux/net/ipv6/datagram.c Fri Sep 7 11:01:21 2001
@@ -5,7 +5,7 @@
X * Authors:
X * Pedro Roque <ro...@di.fc.ul.pt>
X *
- * $Id: datagram.c,v 1.22 2000/12/13 18:31:50 davem Exp $
+ * $Id: datagram.c,v 1.23 2001/09/01 00:31:50 davem Exp $


X *
X * This program is free software; you can redistribute it and/or
X * modify it under the terms of the GNU General Public License

@@ -427,7 +427,8 @@
X break;
X
X default:
- printk(KERN_DEBUG "invalid cmsg type: %d\n", cmsg->cmsg_type);
+ if (net_ratelimit())
+ printk(KERN_DEBUG "invalid cmsg type: %d\n", cmsg->cmsg_type);
X err = -EINVAL;
X break;
X };
diff -u --recursive --new-file v2.4.9/linux/net/ipv6/icmp.c linux/net/ipv6/icmp.c
--- v2.4.9/linux/net/ipv6/icmp.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipv6/icmp.c Thu Sep 20 14:12:56 2001
@@ -5,7 +5,7 @@
X * Authors:
X * Pedro Roque <ro...@di.fc.ul.pt>
X *
- * $Id: icmp.c,v 1.35 2001/08/13 18:56:13 davem Exp $
+ * $Id: icmp.c,v 1.37 2001/09/18 22:29:10 davem Exp $
X *
X * Based on net/ipv4/icmp.c
X *
@@ -322,7 +322,8 @@
X * for now we don't know that.
X */
X if ((addr_type == IPV6_ADDR_ANY) || (addr_type & IPV6_ADDR_MULTICAST)) {
- printk(KERN_DEBUG "icmpv6_send: addr_any/mcast source\n");
+ if (net_ratelimit())
+ printk(KERN_DEBUG "icmpv6_send: addr_any/mcast source\n");
X return;
X }
X
@@ -365,10 +366,11 @@
X msg.daddr = &hdr->saddr;
X
X len = skb->len - msg.offset + sizeof(struct icmp6hdr);
- len = min(unsigned int, len, IPV6_MIN_MTU - sizeof(struct ipv6hdr));
+ len = min_t(unsigned int, len, IPV6_MIN_MTU - sizeof(struct ipv6hdr));
X
X if (len < 0) {
- printk(KERN_DEBUG "icmp: len problem\n");
+ if (net_ratelimit())
+ printk(KERN_DEBUG "icmp: len problem\n");
X goto out;
X }
X
@@ -507,30 +509,32 @@
X skb->ip_summed = CHECKSUM_UNNECESSARY;
X if (csum_ipv6_magic(saddr, daddr, skb->len, IPPROTO_ICMPV6,
X skb->csum)) {
- printk(KERN_DEBUG "ICMPv6 hw checksum failed\n");
+ if (net_ratelimit())
+ printk(KERN_DEBUG "ICMPv6 hw checksum failed\n");
X skb->ip_summed = CHECKSUM_NONE;
X }
X }
X if (skb->ip_summed == CHECKSUM_NONE) {
X if (csum_ipv6_magic(saddr, daddr, skb->len, IPPROTO_ICMPV6,
X skb_checksum(skb, 0, skb->len, 0))) {
- printk(KERN_DEBUG "ICMPv6 checksum failed [%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x > %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x]\n",
- ntohs(saddr->in6_u.u6_addr16[0]),
- ntohs(saddr->in6_u.u6_addr16[1]),
- ntohs(saddr->in6_u.u6_addr16[2]),
- ntohs(saddr->in6_u.u6_addr16[3]),
- ntohs(saddr->in6_u.u6_addr16[4]),
- ntohs(saddr->in6_u.u6_addr16[5]),
- ntohs(saddr->in6_u.u6_addr16[6]),
- ntohs(saddr->in6_u.u6_addr16[7]),
- ntohs(daddr->in6_u.u6_addr16[0]),
- ntohs(daddr->in6_u.u6_addr16[1]),
- ntohs(daddr->in6_u.u6_addr16[2]),
- ntohs(daddr->in6_u.u6_addr16[3]),
- ntohs(daddr->in6_u.u6_addr16[4]),
- ntohs(daddr->in6_u.u6_addr16[5]),
- ntohs(daddr->in6_u.u6_addr16[6]),
- ntohs(daddr->in6_u.u6_addr16[7]));
+ if (net_ratelimit())
+ printk(KERN_DEBUG "ICMPv6 checksum failed [%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x > %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x]\n",
+ ntohs(saddr->in6_u.u6_addr16[0]),
+ ntohs(saddr->in6_u.u6_addr16[1]),
+ ntohs(saddr->in6_u.u6_addr16[2]),
+ ntohs(saddr->in6_u.u6_addr16[3]),
+ ntohs(saddr->in6_u.u6_addr16[4]),
+ ntohs(saddr->in6_u.u6_addr16[5]),
+ ntohs(saddr->in6_u.u6_addr16[6]),
+ ntohs(saddr->in6_u.u6_addr16[7]),
+ ntohs(daddr->in6_u.u6_addr16[0]),
+ ntohs(daddr->in6_u.u6_addr16[1]),
+ ntohs(daddr->in6_u.u6_addr16[2]),
+ ntohs(daddr->in6_u.u6_addr16[3]),
+ ntohs(daddr->in6_u.u6_addr16[4]),
+ ntohs(daddr->in6_u.u6_addr16[5]),
+ ntohs(daddr->in6_u.u6_addr16[6]),
+ ntohs(daddr->in6_u.u6_addr16[7]));
X goto discard_it;
X }
X }
diff -u --recursive --new-file v2.4.9/linux/net/ipv6/ip6_output.c linux/net/ipv6/ip6_output.c
--- v2.4.9/linux/net/ipv6/ip6_output.c Thu Apr 19 08:38:50 2001
+++ linux/net/ipv6/ip6_output.c Thu Sep 20 14:12:56 2001
@@ -5,7 +5,7 @@
X * Authors:
X * Pedro Roque <ro...@di.fc.ul.pt>
X *
- * $Id: ip6_output.c,v 1.31 2001/04/17 20:39:51 davem Exp $
+ * $Id: ip6_output.c,v 1.33 2001/09/20 00:35:35 davem Exp $
X *
X * Based on linux/net/ipv4/ip_output.c
X *
@@ -149,7 +149,8 @@
X dst = ip6_route_output(skb->sk, &fl);
X
X if (dst->error) {
- printk(KERN_DEBUG "route6_me_harder: No more route.\n");
+ if (net_ratelimit())
+ printk(KERN_DEBUG "route6_me_harder: No more route.\n");
X return -EINVAL;
X }
X
@@ -239,7 +240,8 @@
X return NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, dst->dev, ip6_maybe_reroute);
X }
X
- printk(KERN_DEBUG "IPv6: sending pkt_too_big to self\n");
+ if (net_ratelimit())
+ printk(KERN_DEBUG "IPv6: sending pkt_too_big to self\n");
X icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, dst->pmtu, skb->dev);
X kfree_skb(skb);
X return -EMSGSIZE;
@@ -724,7 +726,7 @@
X struct ipv6hdr *hdr = skb->nh.ipv6h;
X struct inet6_skb_parm *opt =(struct inet6_skb_parm*)skb->cb;
X
- if (ipv6_devconf.forwarding == 0 && opt->srcrt == 0)
+ if (ipv6_devconf.forwarding == 0)
X goto error;
X
X skb->ip_summed = CHECKSUM_NONE;
diff -u --recursive --new-file v2.4.9/linux/net/ipv6/ipv6_sockglue.c linux/net/ipv6/ipv6_sockglue.c
--- v2.4.9/linux/net/ipv6/ipv6_sockglue.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipv6/ipv6_sockglue.c Thu Sep 20 14:12:56 2001
@@ -7,7 +7,7 @@
X *
X * Based on linux/net/ipv4/ip_sockglue.c
X *
- * $Id: ipv6_sockglue.c,v 1.39 2001/08/13 18:56:13 davem Exp $
+ * $Id: ipv6_sockglue.c,v 1.40 2001/09/18 22:29:10 davem Exp $
X *


X * This program is free software; you can redistribute it and/or
X * modify it under the terms of the GNU General Public License

@@ -535,7 +535,7 @@
X return -EINVAL;
X #endif
X }


- len = min(unsigned int, sizeof(int), len);
+ len = min_t(unsigned int, sizeof(int), len);
X if(put_user(len, optlen))
X return -EFAULT;
X if(copy_to_user(optval,&val,len))

diff -u --recursive --new-file v2.4.9/linux/net/ipv6/ndisc.c linux/net/ipv6/ndisc.c
--- v2.4.9/linux/net/ipv6/ndisc.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipv6/ndisc.c Mon Sep 10 07:57:00 2001
@@ -846,7 +846,7 @@
X }
X }
X
- rd_len = min(unsigned int,
+ rd_len = min_t(unsigned int,
X IPV6_MIN_MTU-sizeof(struct ipv6hdr)-len, skb->len + 8);
X rd_len &= ~0x7;
X len += rd_len;
diff -u --recursive --new-file v2.4.9/linux/net/ipv6/raw.c linux/net/ipv6/raw.c
--- v2.4.9/linux/net/ipv6/raw.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipv6/raw.c Thu Sep 20 14:12:56 2001
@@ -7,7 +7,7 @@
X *
X * Adapted from linux/net/ipv4/raw.c
X *
- * $Id: raw.c,v 1.49 2001/08/13 18:56:13 davem Exp $
+ * $Id: raw.c,v 1.50 2001/09/18 22:29:10 davem Exp $
X *
X * Fixes:
X * Hideaki YOSHIFUJI : sin6_scope_id support
@@ -699,7 +699,7 @@
X return -ENOPROTOOPT;
X }
X

- len = min(unsigned int, sizeof(int), len);
+ len = min_t(unsigned int, sizeof(int), len);
X

X if (put_user(len, optlen))
X return -EFAULT;
diff -u --recursive --new-file v2.4.9/linux/net/ipv6/route.c linux/net/ipv6/route.c
--- v2.4.9/linux/net/ipv6/route.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipv6/route.c Thu Sep 20 14:12:56 2001
@@ -5,7 +5,7 @@
X * Authors:
X * Pedro Roque <ro...@di.fc.ul.pt>
X *
- * $Id: route.c,v 1.54 2001/08/13 18:56:13 davem Exp $
+ * $Id: route.c,v 1.55 2001/09/18 22:29:10 davem Exp $
X *


X * This program is free software; you can redistribute it and/or
X * modify it under the terms of the GNU General Public License

@@ -785,7 +785,7 @@
X
X install_route:
X rt->u.dst.pmtu = ipv6_get_mtu(dev);
- rt->u.dst.advmss = max(unsigned int, rt->u.dst.pmtu - 60, ip6_rt_min_advmss);
+ rt->u.dst.advmss = max_t(unsigned int, rt->u.dst.pmtu - 60, ip6_rt_min_advmss);
X /* Maximal non-jumbo IPv6 payload is 65535 and corresponding
X MSS is 65535 - tcp_header_size. 65535 is also valid and
X means: "any MSS, rely only on pmtu discovery"
@@ -944,7 +944,7 @@
X nrt->rt6i_nexthop = neigh_clone(neigh);
X /* Reset pmtu, it may be better */
X nrt->u.dst.pmtu = ipv6_get_mtu(neigh->dev);
- nrt->u.dst.advmss = max(unsigned int, nrt->u.dst.pmtu - 60, ip6_rt_min_advmss);
+ nrt->u.dst.advmss = max_t(unsigned int, nrt->u.dst.pmtu - 60, ip6_rt_min_advmss);
X if (rt->u.dst.advmss > 65535-20)
X rt->u.dst.advmss = 65535;
X nrt->rt6i_hoplimit = ipv6_get_hoplimit(neigh->dev);
@@ -1199,7 +1199,7 @@
X rt->u.dst.output = ip6_output;
X rt->rt6i_dev = dev_get_by_name("lo");
X rt->u.dst.pmtu = ipv6_get_mtu(rt->rt6i_dev);
- rt->u.dst.advmss = max(unsigned int, rt->u.dst.pmtu - 60, ip6_rt_min_advmss);
+ rt->u.dst.advmss = max_t(unsigned int, rt->u.dst.pmtu - 60, ip6_rt_min_advmss);
X if (rt->u.dst.advmss > 65535-20)
X rt->u.dst.advmss = 65535;
X rt->rt6i_hoplimit = ipv6_get_hoplimit(rt->rt6i_dev);
@@ -1390,7 +1390,7 @@
X rt->u.dst.pmtu > arg->mtu &&
X !(rt->u.dst.mxlock&(1<<RTAX_MTU)))
X rt->u.dst.pmtu = arg->mtu;
- rt->u.dst.advmss = max(unsigned int, arg->mtu - 60, ip6_rt_min_advmss);
+ rt->u.dst.advmss = max_t(unsigned int, arg->mtu - 60, ip6_rt_min_advmss);
X if (rt->u.dst.advmss > 65535-20)
X rt->u.dst.advmss = 65535;
X return 0;
diff -u --recursive --new-file v2.4.9/linux/net/ipv6/sit.c linux/net/ipv6/sit.c
--- v2.4.9/linux/net/ipv6/sit.c Thu May 24 15:00:59 2001
+++ linux/net/ipv6/sit.c Fri Sep 7 11:01:21 2001
@@ -6,7 +6,7 @@
X * Pedro Roque <ro...@di.fc.ul.pt>
X * Alexey Kuznetsov <kuz...@ms2.inr.ac.ru>
X *
- * $Id: sit.c,v 1.51 2001/05/17 04:12:18 davem Exp $
+ * $Id: sit.c,v 1.52 2001/09/01 00:31:50 davem Exp $


X *
X * This program is free software; you can redistribute it and/or
X * modify it under the terms of the GNU General Public License

@@ -482,7 +482,8 @@
X neigh = skb->dst->neighbour;
X
X if (neigh == NULL) {
- printk(KERN_DEBUG "sit: nexthop == NULL\n");
+ if (net_ratelimit())
+ printk(KERN_DEBUG "sit: nexthop == NULL\n");
X goto tx_error;
X }
X
diff -u --recursive --new-file v2.4.9/linux/net/ipv6/tcp_ipv6.c linux/net/ipv6/tcp_ipv6.c
--- v2.4.9/linux/net/ipv6/tcp_ipv6.c Tue Jul 3 17:08:22 2001
+++ linux/net/ipv6/tcp_ipv6.c Fri Sep 7 11:01:21 2001
@@ -5,7 +5,7 @@
X * Authors:
X * Pedro Roque <ro...@di.fc.ul.pt>
X *
- * $Id: tcp_ipv6.c,v 1.137 2001/06/13 16:25:03 davem Exp $
+ * $Id: tcp_ipv6.c,v 1.138 2001/09/01 00:31:50 davem Exp $
X *
X * Based on:
X * linux/net/ipv4/tcp.c
@@ -1380,7 +1380,7 @@
X if (!tcp_v6_check(skb->h.th,skb->len,&skb->nh.ipv6h->saddr,
X &skb->nh.ipv6h->daddr,skb->csum))
X return 0;
- NETDEBUG(printk(KERN_DEBUG "hw tcp v6 csum failed\n"));
+ NETDEBUG(if (net_ratelimit()) printk(KERN_DEBUG "hw tcp v6 csum failed\n"));
X }
X if (skb->len <= 76) {
X if (tcp_v6_check(skb->h.th,skb->len,&skb->nh.ipv6h->saddr,
diff -u --recursive --new-file v2.4.9/linux/net/ipv6/udp.c linux/net/ipv6/udp.c
--- v2.4.9/linux/net/ipv6/udp.c Tue Jul 3 17:08:22 2001
+++ linux/net/ipv6/udp.c Fri Sep 7 11:01:21 2001
@@ -7,7 +7,7 @@
X *
X * Based on linux/ipv4/udp.c
X *
- * $Id: udp.c,v 1.63 2001/06/13 16:25:03 davem Exp $
+ * $Id: udp.c,v 1.64 2001/09/01 00:31:50 davem Exp $
X *
X * Fixes:
X * Hideaki YOSHIFUJI : sin6_scope_id support
@@ -635,7 +635,7 @@
X if (skb->ip_summed==CHECKSUM_HW) {
X skb->ip_summed = CHECKSUM_UNNECESSARY;
X if (csum_ipv6_magic(saddr, daddr, ulen, IPPROTO_UDP, skb->csum)) {
- NETDEBUG(printk(KERN_DEBUG "udp v6 hw csum failure.\n"));
+ NETDEBUG(if (net_ratelimit()) printk(KERN_DEBUG "udp v6 hw csum failure.\n"));
X skb->ip_summed = CHECKSUM_NONE;
X }
X }
diff -u --recursive --new-file v2.4.9/linux/net/ipx/af_ipx.c linux/net/ipx/af_ipx.c
--- v2.4.9/linux/net/ipx/af_ipx.c Mon Aug 27 12:41:49 2001
+++ linux/net/ipx/af_ipx.c Thu Sep 13 17:16:23 2001
@@ -1890,7 +1890,7 @@
X if (get_user(len, optlen))
X goto out;


X
- len = min(unsigned int, len, sizeof(int));
+ len = min_t(unsigned int, len, sizeof(int));

X ret = -EINVAL;
X if(len < 0)
X goto out;
@@ -2536,7 +2536,7 @@
X
X static unsigned char ipx_8022_type = 0xE0;
X static unsigned char ipx_snap_id[5] = { 0x0, 0x0, 0x0, 0x81, 0x37 };


-static const char banner[] __initdata =
+static char banner[] __initdata =

X KERN_INFO "NET4: Linux IPX 0.47 for NET4.0\n"
X KERN_INFO "IPX Portions Copyright (c) 1995 Caldera, Inc.\n" \
X KERN_INFO "IPX Portions Copyright (c) 2000, 2001 Conectiva, Inc.\n";
diff -u --recursive --new-file v2.4.9/linux/net/ipx/af_spx.c linux/net/ipx/af_spx.c
--- v2.4.9/linux/net/ipx/af_spx.c Tue Jul 3 17:08:22 2001
+++ linux/net/ipx/af_spx.c Thu Sep 13 17:16:23 2001
@@ -910,7 +910,7 @@
X create: spx_create,
X };
X
-static const char banner[] __initdata = KERN_INFO "NET4: Sequenced Packet eXchange (SPX) 0.02 for Linux NET4.0\n";
+static char banner[] __initdata = KERN_INFO "NET4: Sequenced Packet eXchange (SPX) 0.02 for Linux NET4.0\n";
X
X static int __init spx_proto_init(void)
X {
diff -u --recursive --new-file v2.4.9/linux/net/irda/af_irda.c linux/net/irda/af_irda.c
--- v2.4.9/linux/net/irda/af_irda.c Mon Aug 27 12:41:49 2001
+++ linux/net/irda/af_irda.c Fri Sep 14 14:04:08 2001
@@ -98,6 +98,8 @@
X struct sock *sk;
X int err;
X
+ IRDA_DEBUG(3, __FUNCTION__ "()\n");
+
X self = (struct irda_sock *) instance;
X ASSERT(self != NULL, return -1;);
X
@@ -128,10 +130,10 @@
X struct irda_sock *self;


X struct sock *sk;
X

- IRDA_DEBUG(2, __FUNCTION__ "()\n");
-
X self = (struct irda_sock *) instance;
X
+ IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self);
+
X sk = self->sk;
X if (sk == NULL)
X return;
@@ -155,8 +157,10 @@
X * Note : all socket function do check sk->state, so we are safe...
X * Jean II
X */
- irttp_close_tsap(self->tsap);
- self->tsap = NULL;
+ if (self->tsap) {
+ irttp_close_tsap(self->tsap);
+ self->tsap = NULL;
+ }
X
X /* Note : once we are there, there is not much you want to do
X * with the socket anymore, apart from closing it.
@@ -180,10 +184,10 @@
X struct irda_sock *self;


X struct sock *sk;
X

- IRDA_DEBUG(2, __FUNCTION__ "()\n");
-
X self = (struct irda_sock *) instance;
X
+ IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self);
+
X sk = self->sk;
X if (sk == NULL)
X return;
@@ -238,10 +242,10 @@
X struct irda_sock *self;


X struct sock *sk;
X

- IRDA_DEBUG(2, __FUNCTION__ "()\n");
-
X self = (struct irda_sock *) instance;
X
+ IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self);
+
X sk = self->sk;
X if (sk == NULL)
X return;
@@ -358,14 +362,14 @@
X {
X struct irda_sock *self;
X
- IRDA_DEBUG(2, __FUNCTION__ "()\n");
-
X self = (struct irda_sock *) priv;
X if (!self) {
X WARNING(__FUNCTION__ "(), lost myself!\n");
X return;
X }
X
+ IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self);
+
X /* We probably don't need to make any more queries */
X iriap_close(self->iriap);
X self->iriap = NULL;
@@ -539,7 +543,7 @@
X */
X static int irda_find_lsap_sel(struct irda_sock *self, char *name)
X {
- IRDA_DEBUG(2, __FUNCTION__ "(), name=%s\n", name);
+ IRDA_DEBUG(2, __FUNCTION__ "(%p, %s)\n", self, name);
X
X ASSERT(self != NULL, return -1;);
X
@@ -550,6 +554,8 @@
X
X self->iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self,
X irda_getvalue_confirm);
+ if(self->iriap == NULL)
+ return -ENOMEM;
X
X /* Treat unexpected signals as disconnect */
X self->errno = -EHOSTUNREACH;
@@ -777,11 +783,11 @@
X struct irda_sock *self;
X int err;
X
- IRDA_DEBUG(2, __FUNCTION__ "()\n");
-
X self = sk->protinfo.irda;
X ASSERT(self != NULL, return -1;);
X
+ IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self);
+
X if (addr_len != sizeof(struct sockaddr_irda))
X return -EINVAL;
X
@@ -942,10 +948,10 @@
X struct irda_sock *self;
X int err;
X
- IRDA_DEBUG(2, __FUNCTION__ "()\n");
-
X self = sk->protinfo.irda;
X
+ IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self);
+
X /* Don't allow connect for Ultra sockets */
X if ((sk->type == SOCK_DGRAM) && (sk->protocol == IRDAPROTO_ULTRA))
X return -ESOCKTNOSUPPORT;
@@ -1063,22 +1069,29 @@
X return -ESOCKTNOSUPPORT;
X }
X
- /* Allocate socket */
+ /* Allocate networking socket */
X if ((sk = sk_alloc(PF_IRDA, GFP_ATOMIC, 1)) == NULL)
X return -ENOMEM;
-
+
+ /* Allocate IrDA socket */
X self = kmalloc(sizeof(struct irda_sock), GFP_ATOMIC);
X if (self == NULL) {
- kfree (sk);
+ sk_free(sk);
X return -ENOMEM;
X }
X memset(self, 0, sizeof(struct irda_sock));
X
+ IRDA_DEBUG(2, __FUNCTION__ "() : self is %p\n", self);
+
X init_waitqueue_head(&self->query_wait);
X
- self->sk = sk;
+ /* Initialise networking socket struct */
+ sock_init_data(sock, sk); /* Note : set sk->refcnt to 1 */
+ sk->family = PF_IRDA;
+ sk->protocol = protocol;
+ /* Link networking socket and IrDA socket structs together */
X sk->protinfo.irda = self;
- sock_init_data(sock, sk);
+ self->sk = sk;
X
X switch (sock->type) {
X case SOCK_STREAM:
@@ -1110,8 +1123,6 @@
X return -ESOCKTNOSUPPORT;
X }
X
- sk->protocol = protocol;
-
X /* Register as a client with IrLMP */
X self->ckey = irlmp_register_client(0, NULL, NULL, NULL);
X self->mask = 0xffff;
@@ -1133,7 +1144,7 @@
X */
X void irda_destroy_socket(struct irda_sock *self)
X {
- IRDA_DEBUG(2, __FUNCTION__ "()\n");
+ IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self);
X
X ASSERT(self != NULL, return;);
X
@@ -1187,12 +1198,47 @@
X sk->state = TCP_CLOSE;
X sk->shutdown |= SEND_SHUTDOWN;
X sk->state_change(sk);
- sk->dead = 1;
X
+ /* Destroy IrDA socket */
X irda_destroy_socket(sk->protinfo.irda);
+ /* Prevent sock_def_destruct() to create havoc */
+ sk->protinfo.irda = NULL;
X
+ sock_orphan(sk);
X sock->sk = NULL;
- sk->socket = NULL; /* Not used, but we should do this. */
+
+ /* Purge queues (see sock_init_data()) */
+ skb_queue_purge(&sk->receive_queue);
+
+ /* Destroy networking socket if we are the last reference on it,
+ * i.e. if(sk->refcnt == 0) -> sk_free(sk) */
+ sock_put(sk);
+
+ /* Notes on socket locking and deallocation... - Jean II
+ * In theory we should put pairs of sock_hold() / sock_put() to
+ * prevent the socket to be destroyed whenever there is an
+ * outstanding request or outstanding incomming packet or event.
+ *
+ * 1) This may include IAS request, both in connect and getsockopt.
+ * Unfortunately, the situation is a bit more messy than it looks,
+ * because we close iriap and kfree(self) above.
+ *
+ * 2) This may include selective discovery in getsockopt.
+ * Same stuff as above, irlmp registration and self are gone.
+ *
+ * Probably 1 and 2 may not matter, because it's all triggered
+ * by a process and the socket layer already prevent the
+ * socket to go away while a process is holding it, through
+ * sockfd_put() and fput()...
+ *
+ * 3) This may include deferred TSAP closure. In particular,
+ * we may receive a late irda_disconnect_indication()
+ * Fortunately, (tsap_cb *)->close_pend should protect us
+ * from that.
+ *
+ * I did some testing on SMP, and it looks solid. And the socket
+ * memory leak is now gone... - Jean II
+ */


X
X return 0;
X }

@@ -1400,7 +1446,7 @@
X continue;
X }
X
- chunk = min(unsigned int, skb->len, size);
+ chunk = min_t(unsigned int, skb->len, size);
X if (memcpy_toiovec(msg->msg_iov, skb->data, chunk)) {
X skb_queue_head(&sk->receive_queue, skb);
X if (copied == 0)
@@ -1585,11 +1631,11 @@
X struct irda_sock *self;
X struct sock *sk = sock->sk;
X
- IRDA_DEBUG(0, __FUNCTION__ "()\n");
-
X self = sk->protinfo.irda;
X ASSERT(self != NULL, return -1;);
X
+ IRDA_DEBUG(1, __FUNCTION__ "(%p)\n", self);
+
X sk->state = TCP_CLOSE;
X sk->shutdown |= SEND_SHUTDOWN;
X sk->state_change(sk);
@@ -1763,6 +1809,8 @@
X self = sk->protinfo.irda;
X ASSERT(self != NULL, return -1;);
X
+ IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self);
+
X if (level != SOL_IRLMP)
X return -ENOPROTOOPT;
X
@@ -2029,13 +2077,15 @@
X
X self = sk->protinfo.irda;
X
+ IRDA_DEBUG(2, __FUNCTION__ "(%p)\n", self);
+
X if (level != SOL_IRLMP)
X return -ENOPROTOOPT;
X
X if (get_user(len, optlen))
X return -EFAULT;
X
- if(optlen < 0)
+ if(len < 0)
X return -EINVAL;
X
X switch (optname) {
@@ -2057,7 +2107,12 @@
X offset = sizeof(struct irda_device_list) -
X sizeof(struct irda_device_info);
X
- /* Copy the list itself */
+ /* Copy the list itself - watch for overflow */
+ if(list.len > 2048)
+ {
+ err = -EINVAL;
+ goto bed;
+ }
X total = offset + (list.len * sizeof(struct irda_device_info));
X if (total > len)
X total = len;
@@ -2067,7 +2122,7 @@
X /* Write total number of bytes used back to client */
X if (put_user(total, optlen))
X err = -EFAULT;
-
+bed:
X /* Free up our buffer */
X kfree(discoveries);
X if (err)
diff -u --recursive --new-file v2.4.9/linux/net/irda/irda_device.c linux/net/irda/irda_device.c
--- v2.4.9/linux/net/irda/irda_device.c Wed Apr 18 14:40:07 2001
+++ linux/net/irda/irda_device.c Fri Sep 7 09:28:38 2001
@@ -457,15 +457,17 @@
X dongle_t *irda_device_dongle_init(struct net_device *dev, int type)
X {
X struct dongle_reg *reg;
- char modname[32];
X dongle_t *dongle;
X
X ASSERT(dev != NULL, return NULL;);
X
X #ifdef CONFIG_KMOD
+ {
+ char modname[32];
X /* Try to load the module needed */
X sprintf(modname, "irda-dongle-%d", type);
X request_module(modname);
+ }
X #endif /* CONFIG_KMOD */
X
X if (!(reg = hashbin_find(dongles, type, NULL))) {
diff -u --recursive --new-file v2.4.9/linux/net/irda/iriap.c linux/net/irda/iriap.c
--- v2.4.9/linux/net/irda/iriap.c Sat Nov 11 18:11:22 2000
+++ linux/net/irda/iriap.c Thu Sep 13 16:26:52 2001
@@ -379,7 +379,7 @@
X char *name, char *attr)


X {
X struct sk_buff *skb;

- int name_len, attr_len;
+ int name_len, attr_len, skb_len;
X __u8 *frame;
X
X ASSERT(self != NULL, return -1;);
@@ -400,13 +400,14 @@
X /* Give ourselves 10 secs to finish this operation */
X iriap_start_watchdog_timer(self, 10*HZ);
X
- skb = dev_alloc_skb(64);
+ name_len = strlen(name); /* Up to IAS_MAX_CLASSNAME = 60 */
+ attr_len = strlen(attr); /* Up to IAS_MAX_ATTRIBNAME = 60 */
+
+ skb_len = self->max_header_size+2+name_len+1+attr_len+4;
+ skb = dev_alloc_skb(skb_len);
X if (!skb)
X return -ENOMEM;
X
- name_len = strlen(name);
- attr_len = strlen(attr);
-
X /* Reserve space for MUX and LAP header */
X skb_reserve(skb, self->max_header_size);
X skb_put(skb, 3+name_len+attr_len);
@@ -500,20 +501,19 @@
X }
X value_len = fp[n++];
X IRDA_DEBUG(4, __FUNCTION__ "(), strlen=%d\n", value_len);
- ASSERT(value_len < 64, return;);
X
X /* Make sure the string is null-terminated */
X fp[n+value_len] = 0x00;
-
X IRDA_DEBUG(4, "Got string %s\n", fp+n);
+
+ /* Will truncate to IAS_MAX_STRING bytes */
X value = irias_new_string_value(fp+n);
X break;
X case IAS_OCT_SEQ:
X value_len = be16_to_cpu(get_unaligned((__u16 *)(fp+n)));
X n += 2;
X
- ASSERT(value_len <= 55, return;);
-
+ /* Will truncate to IAS_MAX_OCTET_STRING bytes */
X value = irias_new_octseq_value(fp+n, value_len);
X break;
X default:
@@ -635,8 +635,8 @@
X struct ias_attrib *attrib;
X int name_len;
X int attr_len;
- char name[64];
- char attr[64];
+ char name[IAS_MAX_CLASSNAME + 1]; /* 60 bytes */
+ char attr[IAS_MAX_ATTRIBNAME + 1]; /* 60 bytes */
X __u8 *fp;
X int n;
X
@@ -1013,7 +1013,7 @@
X attrib->value->t.string);
X break;
X case IAS_OCT_SEQ:
- len += sprintf(buf+len, "octet sequence\n");
+ len += sprintf(buf+len, "octet sequence (%d bytes)\n", attrib->value->len);
X break;
X case IAS_MISSING:
X len += sprintf(buf+len, "missing\n");
diff -u --recursive --new-file v2.4.9/linux/net/irda/irias_object.c linux/net/irda/irias_object.c
--- v2.4.9/linux/net/irda/irias_object.c Wed Jul 25 17:10:27 2001
+++ linux/net/irda/irias_object.c Thu Sep 13 16:26:52 2001
@@ -37,25 +37,35 @@
X struct ias_value missing = { IAS_MISSING, 0, 0, 0, {0}};
X
X /*
- * Function strdup (str)
+ * Function strndup (str, max)
X *
- * My own kernel version of strdup!
+ * My own kernel version of strndup!
X *
+ * Faster, check boundary... Jean II
X */
-char *strdup(char *str)
+char *strndup(char *str, int max)
X {
X char *new_str;
+ int len;
X
+ /* Check string */
X if (str == NULL)
X return NULL;
-
- ASSERT(strlen( str) < 64, return NULL;);
-
- new_str = kmalloc(strlen(str)+1, GFP_ATOMIC);
- if (new_str == NULL)
+ /* Check length, truncate */
+ len = strlen(str);
+ if(len > max)
+ len = max;
+
+ /* Allocate new string */
+ new_str = kmalloc(len + 1, GFP_ATOMIC);
+ if (new_str == NULL) {
+ WARNING(__FUNCTION__"(), Unable to kmalloc!\n");
X return NULL;
-
- strcpy(new_str, str);
+ }
+
+ /* Copy and truncate */
+ memcpy(new_str, str, len);
+ new_str[len] = '\0';
X
X return new_str;
X }
@@ -81,7 +91,7 @@
X memset(obj, 0, sizeof( struct ias_object));
X
X obj->magic = IAS_OBJECT_MAGIC;
- obj->name = strdup( name);
+ obj->name = strndup(name, IAS_MAX_CLASSNAME);
X obj->id = id;
X
X obj->attribs = hashbin_new(HB_LOCAL);
@@ -315,7 +325,7 @@
X memset(attrib, 0, sizeof( struct ias_attrib));
X
X attrib->magic = IAS_ATTRIB_MAGIC;
- attrib->name = strdup(name);
+ attrib->name = strndup(name, IAS_MAX_ATTRIBNAME);
X
X /* Insert value */
X attrib->value = irias_new_integer_value(value);
@@ -351,7 +361,7 @@
X memset(attrib, 0, sizeof( struct ias_attrib));
X
X attrib->magic = IAS_ATTRIB_MAGIC;
- attrib->name = strdup( name);
+ attrib->name = strndup(name, IAS_MAX_ATTRIBNAME);
X
X attrib->value = irias_new_octseq_value( octets, len);
X
@@ -384,7 +394,7 @@
X memset(attrib, 0, sizeof( struct ias_attrib));
X
X attrib->magic = IAS_ATTRIB_MAGIC;
- attrib->name = strdup(name);
+ attrib->name = strndup(name, IAS_MAX_ATTRIBNAME);
X
X attrib->value = irias_new_string_value(value);
X
@@ -420,10 +430,13 @@
X *
X * Create new IAS string value
X *
+ * Per IrLMP 1.1, 4.3.3.2, strings are up to 256 chars - Jean II
X */
X struct ias_value *irias_new_string_value(char *string)
X {
X struct ias_value *value;
+ int len;
+ char *new_str;
X
X value = kmalloc(sizeof(struct ias_value), GFP_ATOMIC);
X if (value == NULL) {
@@ -434,8 +447,8 @@
X
X value->type = IAS_STRING;
X value->charset = CS_ASCII;
- value->len = strlen(string);
- value->t.string = strdup(string);
+ value->t.string = strndup(string, IAS_MAX_STRING);
+ value->len = strlen(value->t.string);
X
X return value;
X }
@@ -446,6 +459,7 @@
X *
X * Create new IAS octet-sequence value
X *
+ * Per IrLMP 1.1, 4.3.3.2, octet-sequence are up to 1024 bytes - Jean II
X */
X struct ias_value *irias_new_octseq_value(__u8 *octseq , int len)
X {
@@ -459,11 +473,15 @@
X memset(value, 0, sizeof(struct ias_value));
X
X value->type = IAS_OCT_SEQ;
+ /* Check length */
+ if(len > IAS_MAX_OCTET_STRING)
+ len = IAS_MAX_OCTET_STRING;
X value->len = len;
X
X value->t.oct_seq = kmalloc(len, GFP_ATOMIC);
X if (value->t.oct_seq == NULL){
X WARNING(__FUNCTION__"(), Unable to kmalloc!\n");
+ kfree(value);
X return NULL;
X }
X memcpy(value->t.oct_seq, octseq , len);
diff -u --recursive --new-file v2.4.9/linux/net/irda/irlap.c linux/net/irda/irlap.c
--- v2.4.9/linux/net/irda/irlap.c Wed Jul 25 17:10:27 2001
+++ linux/net/irda/irlap.c Thu Sep 13 16:26:52 2001
@@ -94,7 +94,8 @@
X * Initialize IrLAP layer
X *
X */
-struct irlap_cb *irlap_open(struct net_device *dev, struct qos_info *qos)
+struct irlap_cb *irlap_open(struct net_device *dev, struct qos_info *qos,
+ char * hw_name)
X {
X struct irlap_cb *self;
X
@@ -111,6 +112,13 @@
X /* Make a binding between the layers */
X self->netdev = dev;
X self->qos_dev = qos;
+ /* Copy hardware name */
+ if(hw_name != NULL) {
+ strncpy(self->hw_name, hw_name, 2*IFNAMSIZ);
+ self->hw_name[2*IFNAMSIZ] = '\0';
+ } else {
+ self->hw_name[0] = '\0';
+ }
X
X /* FIXME: should we get our own field? */
X dev->atalk_ptr = self;
@@ -1101,6 +1109,10 @@
X len += sprintf(buf+len, "state: %s\n",
X irlap_state[self->state]);
X
+ len += sprintf(buf+len, " device name: %s, ",
+ (self->netdev) ? self->netdev->name : "bug");
+ len += sprintf(buf+len, "hardware name: %s\n", self->hw_name);
+
X len += sprintf(buf+len, " caddr: %#02x, ", self->caddr);
X len += sprintf(buf+len, "saddr: %#08x, ", self->saddr);
X len += sprintf(buf+len, "daddr: %#08x\n", self->daddr);
diff -u --recursive --new-file v2.4.9/linux/net/irda/irlap_event.c linux/net/irda/irlap_event.c
--- v2.4.9/linux/net/irda/irlap_event.c Wed Jul 25 17:10:27 2001
+++ linux/net/irda/irlap_event.c Thu Sep 13 16:26:52 2001
@@ -2018,7 +2018,7 @@
X {


X int ret = 0;
X

- IRDA_DEBUG(0, __FUNCTION__ "()\n");
+ IRDA_DEBUG(1, __FUNCTION__ "()\n");
X
X ASSERT(self != NULL, return -ENODEV;);
X ASSERT(self->magic == LAP_MAGIC, return -EBADR;);
@@ -2048,6 +2048,9 @@
X irlap_disconnect_indication(self, LAP_DISC_INDICATION);
X break;
X case WD_TIMER_EXPIRED:
+ /* Always switch state before calling upper layers */
+ irlap_next_state(self, LAP_NDM);
+
X irlap_apply_default_connection_parameters(self);
X
X irlap_disconnect_indication(self, LAP_DISC_INDICATION);
diff -u --recursive --new-file v2.4.9/linux/net/irda/irlmp.c linux/net/irda/irlmp.c
--- v2.4.9/linux/net/irda/irlmp.c Wed Jul 25 17:10:27 2001
+++ linux/net/irda/irlmp.c Thu Sep 13 16:26:52 2001
@@ -49,6 +49,7 @@
X int sysctl_discovery = 0;
X int sysctl_discovery_timeout = 3; /* 3 seconds by default */
X int sysctl_discovery_slots = 6; /* 6 slots by default */
+int sysctl_lap_keepalive_time = LM_IDLE_TIMEOUT * 1000 / HZ;
X char sysctl_devname[65];
X
X char *lmp_reasons[] = {
@@ -693,10 +694,43 @@
X }
X
X /*
+ * Function irlmp_do_expiry (void)
+ *
+ * Do a cleanup of the discovery log (remove old entries)
+ *
+ * Note : separate from irlmp_do_discovery() so that we can handle
+ * passive discovery properly.
+ */
+void irlmp_do_expiry()
+{
+ struct lap_cb *lap;
+
+ /*
+ * Expire discovery on all links which are *not* connected.
+ * On links which are connected, we can't do discovery
+ * anymore and can't refresh the log, so we freeze the
+ * discovery log to keep info about the device we are
+ * connected to. - Jean II
+ */
+ lap = (struct lap_cb *) hashbin_get_first(irlmp->links);
+ while (lap != NULL) {
+ ASSERT(lap->magic == LMP_LAP_MAGIC, return;);
+
+ if (lap->lap_state == LAP_STANDBY) {
+ /* Expire discoveries discovered on this link */
+ irlmp_expire_discoveries(irlmp->cachelog, lap->saddr,
+ FALSE);
+ }
+ lap = (struct lap_cb *) hashbin_get_next(irlmp->links);
+ }
+}
+
+/*
X * Function irlmp_do_discovery (nslots)
X *
X * Do some discovery on all links
X *
+ * Note : log expiry is done above.
X */
X void irlmp_do_discovery(int nslots)
X {
@@ -731,10 +765,6 @@
X ASSERT(lap->magic == LMP_LAP_MAGIC, return;);
X
X if (lap->lap_state == LAP_STANDBY) {
- /* Expire discoveries discovered on this link */
- irlmp_expire_discoveries(irlmp->cachelog, lap->saddr,
- FALSE);
-
X /* Try to discover */
X irlmp_do_lap_event(lap, LM_LAP_DISCOVERY_REQUEST,
X NULL);
@@ -764,6 +794,9 @@
X */
X if (!sysctl_discovery)
X irlmp_do_discovery(nslots);
+ /* Note : we never do expiry here. Expiry will run on the
+ * discovery timer regardless of the state of sysctl_discovery
+ * Jean II */
X }
X
X /*
diff -u --recursive --new-file v2.4.9/linux/net/irda/irlmp_event.c linux/net/irda/irlmp_event.c
--- v2.4.9/linux/net/irda/irlmp_event.c Wed Jul 25 17:10:27 2001
+++ linux/net/irda/irlmp_event.c Thu Sep 13 16:26:52 2001
@@ -150,6 +150,10 @@
X {
X IRDA_DEBUG(4, __FUNCTION__ "()\n");
X
+ /* We always cleanup the log (active & passive discovery) */
+ irlmp_do_expiry();
+
+ /* Active discovery is conditional */
X if (sysctl_discovery)
X irlmp_do_discovery(sysctl_discovery_slots);
X
@@ -205,10 +209,6 @@
X
X irlap_discovery_request(self->irlap, &irlmp->discovery_cmd);
X break;
- case LM_LAP_DISCOVERY_CONFIRM:
- /* irlmp_next_station_state( LMP_READY); */
- irlmp_discovery_confirm(irlmp->cachelog);
- break;
X case LM_LAP_CONNECT_INDICATION:
X /* It's important to switch state first, to avoid IrLMP to
X * think that the link is free since IrLMP may then start
@@ -274,6 +274,12 @@
X irlmp_do_lsap_event(lsap, LM_LAP_CONNECT_CONFIRM, NULL);
X lsap = (struct lsap_cb*) hashbin_get_next(self->lsaps);
X }
+ /* Note : by the time we get there (LAP retries and co),
+ * the lsaps may already have gone. This avoid getting stuck
+ * forever in LAP_ACTIVE state - Jean II */
+ if (HASHBIN_GET_SIZE(self->lsaps) == 0) {
+ irlmp_start_idle_timer(self, LM_IDLE_TIMEOUT);
+ }
X break;
X case LM_LAP_CONNECT_REQUEST:
X /* Already trying to connect */
@@ -288,6 +294,12 @@
X irlmp_do_lsap_event(lsap, LM_LAP_CONNECT_CONFIRM, NULL);
X lsap = (struct lsap_cb*) hashbin_get_next(self->lsaps);
X }
+ /* Note : by the time we get there (LAP retries and co),
+ * the lsaps may already have gone. This avoid getting stuck
+ * forever in LAP_ACTIVE state - Jean II */
+ if (HASHBIN_GET_SIZE(self->lsaps) == 0) {
+ irlmp_start_idle_timer(self, LM_IDLE_TIMEOUT);
+ }
X break;
X case LM_LAP_DISCONNECT_INDICATION:
X irlmp_next_lap_state(self, LAP_STANDBY);
@@ -375,9 +387,15 @@
X * must be the one that tries to close IrLAP. It will be
X * removed later and moved to the list of unconnected LSAPs
X */
- if (HASHBIN_GET_SIZE(self->lsaps) > 0)
- irlmp_start_idle_timer(self, LM_IDLE_TIMEOUT);
- else {
+ if (HASHBIN_GET_SIZE(self->lsaps) > 0) {
+ /* Make sure the timer has sensible value (the user
+ * may have set it) - Jean II */
+ if(sysctl_lap_keepalive_time < 100) /* 100ms */
+ sysctl_lap_keepalive_time = 100;
+ if(sysctl_lap_keepalive_time > 10000) /* 10s */
+ sysctl_lap_keepalive_time = 10000;
+ irlmp_start_idle_timer(self, sysctl_lap_keepalive_time * HZ / 1000);
+ } else {
X /* No more connections, so close IrLAP */
X
X /* We don't want to change state just yet, because
diff -u --recursive --new-file v2.4.9/linux/net/irda/irlmp_frame.c linux/net/irda/irlmp_frame.c
--- v2.4.9/linux/net/irda/irlmp_frame.c Fri Mar 2 11:12:12 2001
+++ linux/net/irda/irlmp_frame.c Thu Sep 13 16:26:52 2001
@@ -359,8 +359,9 @@
X self = (struct lap_cb *) priv;
X ASSERT(self != NULL, return;);
X
- /* Just handle it the same way as a discovery confirm */
- irlmp_do_lap_event(self, LM_LAP_DISCOVERY_CONFIRM, NULL);
+ /* Just handle it the same way as a discovery confirm,
+ * bypass the LM_LAP state machine (see below) */
+ irlmp_discovery_confirm(irlmp->cachelog);
X }
X
X /*
@@ -377,8 +378,12 @@
X * we always get ~100% of these.
X * o Make faster discovery, statistically divide time of discovery
X * events by 2 (important for the latency aspect and user feel)
+ * o Even is we do active discovery, the other node might not
+ * answer our discoveries (ex: Palm).
+ *
X * However, when both devices discover each other, they might attempt to
- * connect to each other, and it would create collisions on the medium.
+ * connect to each other following the discovery event, and it would create
+ * collisions on the medium (SNRM battle).
X * The trick here is to defer the event by a little delay to avoid both
X * devices to jump in exactly at the same time...
X *
@@ -387,6 +392,14 @@
X * period/timeout that may be set is 1s). The message triggering this
X * event was the last of the discovery, so the medium is now free...
X * Maybe more testing is needed to get the value right...
+
+ * One more problem : the other node might do only a single discovery
+ * and connect immediately to us, and we would receive only a single
+ * discovery indication event, and because of the delay, it will arrive
+ * while the LAP is connected. That's another good reason to
+ * bypass the LM_LAP state machine ;-)
+ *
+ * Jean II
X */
X void irlmp_link_discovery_indication(struct lap_cb *self,
X discovery_t *discovery)
@@ -427,8 +440,13 @@
X if(timer_pending(&disco_delay))
X del_timer(&disco_delay);
X
- /* Propagate event to the state machine */
- irlmp_do_lap_event(self, LM_LAP_DISCOVERY_CONFIRM, NULL);
+ /* Propagate event to various LSAPs registered for it.
+ * We bypass the LM_LAP state machine because
+ * 1) We do it regardless of the LM_LAP state
+ * 2) It doesn't affect the LM_LAP state
+ * 3) Faster, slimer, simpler, ...
+ * Jean II */
+ irlmp_discovery_confirm(irlmp->cachelog);
X }
X
X #ifdef CONFIG_IRDA_CACHE_LAST_LSAP
diff -u --recursive --new-file v2.4.9/linux/net/irda/irnet/irnet.h linux/net/irda/irnet/irnet.h
--- v2.4.9/linux/net/irda/irnet/irnet.h Tue Jul 3 17:08:22 2001
+++ linux/net/irda/irnet/irnet.h Thu Sep 13 16:26:52 2001
@@ -185,6 +185,13 @@
X * is transparently controlled from pppd lcp-max-configure.
X * o Add ttp_connect flag to prevent rentry on the connect procedure
X * o Test and fixups to eliminate side effects of retries
+ *
+ * v7 - 22/08/01 - Jean II
+ * o Cleanup : Change "saddr = 0x0" to "saddr = DEV_ADDR_ANY"
+ * o Fix bug in BLOCK_WHEN_CONNECT introduced in v6 : due to the
+ * asynchronous IAS query, self->tsap is NULL when PPP send the
+ * first packet. This was preventing "connect-delay 0" to work.
+ * Change the test in ppp_irnet_send() to self->ttp_connect.
X */
X
X /***************************** INCLUDES *****************************/
diff -u --recursive --new-file v2.4.9/linux/net/irda/irnet/irnet_irda.c linux/net/irda/irnet/irnet_irda.c
--- v2.4.9/linux/net/irda/irnet/irnet_irda.c Tue Jul 3 17:08:22 2001
+++ linux/net/irda/irnet/irnet_irda.c Thu Sep 13 16:26:52 2001
@@ -478,9 +478,9 @@
X self->ttp_connect = 0; /* Not connecting yet */
X self->rname[0] = '\0'; /* May be set via control channel */
X self->rdaddr = DEV_ADDR_ANY; /* May be set via control channel */
- self->rsaddr = 0x0; /* May be set via control channel */
+ self->rsaddr = DEV_ADDR_ANY; /* May be set via control channel */
X self->daddr = DEV_ADDR_ANY; /* Until we get connected */
- self->saddr = 0x0; /* Until we get connected */
+ self->saddr = DEV_ADDR_ANY; /* Until we get connected */
X self->max_sdu_size_rx = TTP_SAR_UNBOUND;
X
X /* Register as a client with IrLMP */
diff -u --recursive --new-file v2.4.9/linux/net/irda/irnet/irnet_ppp.c linux/net/irda/irnet/irnet_ppp.c
--- v2.4.9/linux/net/irda/irnet/irnet_ppp.c Tue Jul 3 17:08:22 2001
+++ linux/net/irda/irnet/irnet_ppp.c Thu Sep 13 16:26:52 2001
@@ -858,8 +858,8 @@
X irda_irnet_connect(self);
X #endif /* CONNECT_IN_SEND */
X
- DEBUG(PPP_INFO, "IrTTP not ready ! (%d-0x%X)\n",
- self->ttp_open, (unsigned int) self->tsap);
+ DEBUG(PPP_INFO, "IrTTP not ready ! (%d-%d)\n",
+ self->ttp_open, self->ttp_connect);
X
X /* Note : we can either drop the packet or block the packet.
X *
@@ -882,7 +882,7 @@
X */
X #ifdef BLOCK_WHEN_CONNECT
X /* If we are attempting to connect */
- if(self->tsap)
+ if(self->ttp_connect)
X {
X /* Blocking packet, ppp_generic will retry later */
X return 0;
diff -u --recursive --new-file v2.4.9/linux/net/irda/irsysctl.c linux/net/irda/irsysctl.c
--- v2.4.9/linux/net/irda/irsysctl.c Wed Jul 25 17:10:27 2001
+++ linux/net/irda/irsysctl.c Thu Sep 13 16:26:52 2001
@@ -33,7 +33,7 @@
X
X #define NET_IRDA 412 /* Random number */
X enum { DISCOVERY=1, DEVNAME, DEBUG, SLOTS, DISCOVERY_TIMEOUT,
- SLOT_TIMEOUT, MAX_BAUD_RATE, MAX_INACTIVE_TIME };
+ SLOT_TIMEOUT, MAX_BAUD_RATE, MAX_INACTIVE_TIME, LAP_KEEPALIVE_TIME, };
X
X extern int sysctl_discovery;
X extern int sysctl_discovery_slots;
@@ -44,6 +44,7 @@
X extern char sysctl_devname[];
X extern int sysctl_max_baud_rate;
X extern int sysctl_max_inactive_time;
+extern int sysctl_lap_keepalive_time;
X
X #ifdef CONFIG_IRDA_DEBUG
X extern unsigned int irda_debug;
@@ -88,6 +89,8 @@
X { MAX_BAUD_RATE, "max_baud_rate", &sysctl_max_baud_rate,
X sizeof(int), 0644, NULL, &proc_dointvec },
X { MAX_INACTIVE_TIME, "max_inactive_time", &sysctl_max_inactive_time,
+ sizeof(int), 0644, NULL, &proc_dointvec },
+ { LAP_KEEPALIVE_TIME, "lap_keepalive_time", &sysctl_lap_keepalive_time,
X sizeof(int), 0644, NULL, &proc_dointvec },
X { 0 }
X };
diff -u --recursive --new-file v2.4.9/linux/net/khttpd/datasending.c linux/net/khttpd/datasending.c
--- v2.4.9/linux/net/khttpd/datasending.c Mon Aug 27 12:41:49 2001
+++ linux/net/khttpd/datasending.c Mon Sep 10 07:58:35 2001
@@ -105,8 +105,8 @@
X
X Space = sock_wspace(CurrentRequest->sock->sk);
X
- ReadSize = min(int, 4 * 4096, CurrentRequest->FileLength - CurrentRequest->BytesSent);
- ReadSize = min(int, ReadSize, Space);
+ ReadSize = min_t(int, 4 * 4096, CurrentRequest->FileLength - CurrentRequest->BytesSent);
+ ReadSize = min_t(int, ReadSize, Space);
X
X if (ReadSize>0)
X {
diff -u --recursive --new-file v2.4.9/linux/net/khttpd/rfc.c linux/net/khttpd/rfc.c
--- v2.4.9/linux/net/khttpd/rfc.c Mon Aug 27 12:41:49 2001
+++ linux/net/khttpd/rfc.c Mon Sep 10 07:57:00 2001
@@ -326,9 +326,9 @@
X
X strncpy(Head->FileName,sysctl_khttpd_docroot,sizeof(Head->FileName));
X PrefixLen = strlen(sysctl_khttpd_docroot);
- Head->FileNameLength = min(unsigned int, 255, tmp - Buffer + PrefixLen);
+ Head->FileNameLength = min_t(unsigned int, 255, tmp - Buffer + PrefixLen);
X
- strncat(Head->FileName,Buffer,min(unsigned int, 255 - PrefixLen, tmp - Buffer));
+ strncat(Head->FileName,Buffer,min_t(unsigned int, 255 - PrefixLen, tmp - Buffer));
X
X Buffer=EOL+1;
X #ifdef BENCHMARK
@@ -341,7 +341,7 @@
X {
X Buffer+=19;
X
- strncpy(Head->IMS,Buffer,min(unsigned int, 127,EOL-Buffer-1));
+ strncpy(Head->IMS,Buffer,min_t(unsigned int, 127,EOL-Buffer-1));
X
X Buffer=EOL+1;
X continue;
@@ -351,7 +351,7 @@
X {
X Buffer+=12;
X
- strncpy(Head->Agent,Buffer,min(unsigned int, 127,EOL-Buffer-1));
+ strncpy(Head->Agent,Buffer,min_t(unsigned int, 127,EOL-Buffer-1));
X
X Buffer=EOL+1;
X continue;
@@ -362,7 +362,7 @@
X {
X Buffer+=6;
X
- strncpy(Head->Host,Buffer,min(unsigned int, 127,EOL-Buffer-1));
+ strncpy(Head->Host,Buffer,min_t(unsigned int, 127,EOL-Buffer-1));
X
X Buffer=EOL+1;
X continue;
diff -u --recursive --new-file v2.4.9/linux/net/khttpd/waitheaders.c linux/net/khttpd/waitheaders.c
--- v2.4.9/linux/net/khttpd/waitheaders.c Mon Aug 27 12:41:49 2001
+++ linux/net/khttpd/waitheaders.c Mon Sep 10 07:57:00 2001
@@ -244,7 +244,7 @@
X Request->Time = Request->filp->f_dentry->d_inode->i_mtime;
X Request->IMS_Time = mimeTime_to_UnixTime(Request->IMS);
X sprintf(Request->LengthS,"%i",Request->FileLength);
- time_Unix2RFC(min(unsigned int, Request->Time,CurrentTime_i),Request->TimeS);
+ time_Unix2RFC(min_t(unsigned int, Request->Time,CurrentTime_i),Request->TimeS);
X /* The min() is required by rfc1945, section 10.10:
X It is not allowed to send a filetime in the future */
X
diff -u --recursive --new-file v2.4.9/linux/net/lapb/lapb_iface.c linux/net/lapb/lapb_iface.c
--- v2.4.9/linux/net/lapb/lapb_iface.c Thu Apr 12 12:16:36 2001
+++ linux/net/lapb/lapb_iface.c Fri Sep 7 09:28:38 2001
@@ -397,7 +397,7 @@
X EXPORT_SYMBOL(lapb_data_request);
X EXPORT_SYMBOL(lapb_data_received);
X
-static const char banner[] __initdata = KERN_INFO "NET4: LAPB for Linux. Version 0.01 for NET4.0\n";
+static char banner[] __initdata = KERN_INFO "NET4: LAPB for Linux. Version 0.01 for NET4.0\n";
X
X static int __init lapb_init(void)
X {
diff -u --recursive --new-file v2.4.9/linux/net/netrom/af_netrom.c linux/net/netrom/af_netrom.c
--- v2.4.9/linux/net/netrom/af_netrom.c Mon Aug 27 12:41:50 2001
+++ linux/net/netrom/af_netrom.c Mon Sep 10 07:58:35 2001
@@ -435,7 +435,7 @@
X return -ENOPROTOOPT;
X }


X
- len = min(unsigned int, len, sizeof(int));
+ len = min_t(unsigned int, len, sizeof(int));
X

X if (put_user(len, optlen))
X return -EFAULT;
@@ -1262,7 +1262,7 @@
X
X static struct net_device *dev_nr;
X
-static const char banner[] __initdata = KERN_INFO "G4KLX NET/ROM for Linux. Version 0.7 for AX25.037 Linux 2.4\n";
+static char banner[] __initdata = KERN_INFO "G4KLX NET/ROM for Linux. Version 0.7 for AX25.037 Linux 2.4\n";


SHAR_EOF
true || echo 'restore of patch-2.4.10 failed'
fi

echo 'End of part 196'
echo 'File patch-2.4.10 is continued in part 197'
echo "197" > _shar_seq_.tmp
exit 0

Thomas Kobienia

unread,
Sep 24, 2001, 8:01:00 PM9/24/01
to
Archive-name: v2.4/patch-2.4.10/part197

#!/bin/sh -x
# this is part 197 of a 197 - part archive


# do not concatenate these parts, unpack them in order with /bin/sh
# file patch-2.4.10 continued
if test ! -r _shar_seq_.tmp; then
echo 'Please unpack part 1 first!'
exit 1
fi
(read Scheck

if test "$Scheck" != 197; then


echo "Please unpack part $Scheck next!"
exit 1
else
exit 0
fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
echo 'x - still skipping patch-2.4.10'
else
echo 'x - continuing with patch-2.4.10'
sed 's/^X//' << 'SHAR_EOF' >> 'patch-2.4.10' &&

X
X static int __init nr_proto_init(void)
X {
diff -u --recursive --new-file v2.4.9/linux/net/netsyms.c linux/net/netsyms.c
--- v2.4.9/linux/net/netsyms.c Sun Aug 12 13:28:01 2001
+++ linux/net/netsyms.c Tue Sep 18 13:39:51 2001
@@ -504,8 +504,6 @@
X EXPORT_SYMBOL(dev_mc_add);
X EXPORT_SYMBOL(dev_mc_delete);
X EXPORT_SYMBOL(dev_mc_upload);
-EXPORT_SYMBOL(n_tty_ioctl);
-EXPORT_SYMBOL(tty_register_ldisc);
X EXPORT_SYMBOL(__kill_fasync);
X
X EXPORT_SYMBOL(if_port_text);
diff -u --recursive --new-file v2.4.9/linux/net/rose/af_rose.c linux/net/rose/af_rose.c
--- v2.4.9/linux/net/rose/af_rose.c Mon Aug 27 12:41:50 2001
+++ linux/net/rose/af_rose.c Mon Sep 10 07:58:35 2001
@@ -508,7 +508,7 @@


X return -ENOPROTOOPT;
X }
X
- len = min(unsigned int, len, sizeof(int));
+ len = min_t(unsigned int, len, sizeof(int));
X
X if (put_user(len, optlen))
X return -EFAULT;

diff -u --recursive --new-file v2.4.9/linux/net/sched/sch_tbf.c linux/net/sched/sch_tbf.c
--- v2.4.9/linux/net/sched/sch_tbf.c Mon Aug 27 12:41:50 2001
+++ linux/net/sched/sch_tbf.c Mon Sep 10 07:59:25 2001
@@ -227,7 +227,7 @@
X }
X
X if (!netif_queue_stopped(sch->dev)) {
- long delay = PSCHED_US2JIFFIE(max(long, -toks, -ptoks));
+ long delay = PSCHED_US2JIFFIE(max_t(long, -toks, -ptoks));
X
X if (delay == 0)
X delay = 1;
diff -u --recursive --new-file v2.4.9/linux/net/socket.c linux/net/socket.c
--- v2.4.9/linux/net/socket.c Wed Jul 25 17:10:27 2001
+++ linux/net/socket.c Tue Aug 28 10:56:06 2001
@@ -303,8 +303,7 @@
X }
X
X static struct vfsmount *sock_mnt;
-static DECLARE_FSTYPE(sock_fs_type, "sockfs", sockfs_read_super,
- FS_NOMOUNT|FS_SINGLE);
+static DECLARE_FSTYPE(sock_fs_type, "sockfs", sockfs_read_super, FS_NOMOUNT);
X static int sockfs_delete_dentry(struct dentry *dentry)
X {
X return 1;
@@ -1205,13 +1204,14 @@
X msg.msg_iovlen=1;
X msg.msg_control=NULL;
X msg.msg_controllen=0;
- msg.msg_namelen=addr_len;
+ msg.msg_namelen=0;
X if(addr)
X {
X err = move_addr_to_kernel(addr, addr_len, address);
X if (err < 0)
X goto out_put;
X msg.msg_name=address;
+ msg.msg_namelen=addr_len;
X }
X if (sock->file->f_flags & O_NONBLOCK)
X flags |= MSG_DONTWAIT;
diff -u --recursive --new-file v2.4.9/linux/net/sunrpc/auth.c linux/net/sunrpc/auth.c
--- v2.4.9/linux/net/sunrpc/auth.c Mon Aug 27 12:41:50 2001
+++ linux/net/sunrpc/auth.c Fri Sep 21 11:24:50 2001
@@ -69,7 +69,7 @@
X auth->au_ops->destroy(auth);
X }
X
-spinlock_t rpc_credcache_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t rpc_credcache_lock = SPIN_LOCK_UNLOCKED;
X
X /*
X * Initialize RPC credential cache
diff -u --recursive --new-file v2.4.9/linux/net/sunrpc/clnt.c linux/net/sunrpc/clnt.c
--- v2.4.9/linux/net/sunrpc/clnt.c Thu Apr 19 08:38:50 2001
+++ linux/net/sunrpc/clnt.c Fri Sep 21 11:24:50 2001
@@ -55,6 +55,8 @@
X static void call_refreshresult(struct rpc_task *task);
X static void call_timeout(struct rpc_task *task);
X static void call_reconnect(struct rpc_task *task);
+static void child_reconnect(struct rpc_task *);
+static void child_reconnect_status(struct rpc_task *);
X static u32 * call_header(struct rpc_task *task);
X static u32 * call_verify(struct rpc_task *task);
X
@@ -79,7 +81,6 @@
X #ifdef RPC_DEBUG
X rpc_register_sysctl();
X #endif
- xdr_init();
X
X if (!xprt)
X goto out;
@@ -526,6 +527,7 @@
X call_reconnect(struct rpc_task *task)
X {
X struct rpc_clnt *clnt = task->tk_client;
+ struct rpc_task *child;
X
X dprintk("RPC: %4d call_reconnect status %d\n",
X task->tk_pid, task->tk_status);
@@ -533,8 +535,29 @@
X task->tk_action = call_transmit;
X if (task->tk_status < 0 || !clnt->cl_xprt->stream)
X return;
- clnt->cl_stats->netreconn++;
+
+ /* Run as a child to ensure it runs as an rpciod task */
+ child = rpc_new_child(clnt, task);
+ if (child) {
+ child->tk_action = child_reconnect;
+ rpc_run_child(task, child, NULL);
+ }
+}
+
+static void child_reconnect(struct rpc_task *task)
+{
+ task->tk_client->cl_stats->netreconn++;
+ task->tk_status = 0;
+ task->tk_action = child_reconnect_status;
X xprt_reconnect(task);
+}
+
+static void child_reconnect_status(struct rpc_task *task)
+{
+ if (task->tk_status == -EAGAIN)
+ task->tk_action = child_reconnect;
+ else
+ task->tk_action = NULL;
X }
X
X /*
diff -u --recursive --new-file v2.4.9/linux/net/sunrpc/pmap_clnt.c linux/net/sunrpc/pmap_clnt.c
--- v2.4.9/linux/net/sunrpc/pmap_clnt.c Wed Jun 21 12:43:37 2000
+++ linux/net/sunrpc/pmap_clnt.c Fri Sep 21 11:24:50 2001
@@ -31,7 +31,7 @@
X static struct rpc_clnt * pmap_create(char *, struct sockaddr_in *, int);
X static void pmap_getport_done(struct rpc_task *);
X extern struct rpc_program pmap_program;
-spinlock_t pmap_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t pmap_lock = SPIN_LOCK_UNLOCKED;
X
X /*
X * Obtain the port for a given RPC service on a given host. This one can
diff -u --recursive --new-file v2.4.9/linux/net/sunrpc/sched.c linux/net/sunrpc/sched.c
--- v2.4.9/linux/net/sunrpc/sched.c Tue Apr 3 13:45:37 2001
+++ linux/net/sunrpc/sched.c Fri Sep 21 11:24:50 2001
@@ -76,7 +76,7 @@
X /*
X * Spinlock for other critical sections of code.
X */
-spinlock_t rpc_sched_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t rpc_sched_lock = SPIN_LOCK_UNLOCKED;
X
X /*
X * This is the last-ditch buffer for NFS swap requests
@@ -1059,17 +1059,13 @@
X rpciod_pid = current->pid;
X up(&rpciod_running);
X
- exit_fs(current);
- exit_files(current);
- exit_mm(current);
+ daemonize();
X
X spin_lock_irq(&current->sigmask_lock);
X siginitsetinv(&current->blocked, sigmask(SIGKILL));
X recalc_sigpending(current);
X spin_unlock_irq(&current->sigmask_lock);
X
- current->session = 1;
- current->pgrp = 1;
X strcpy(current->comm, "rpciod");
X
X current->flags |= PF_MEMALLOC;
diff -u --recursive --new-file v2.4.9/linux/net/sunrpc/sunrpc_syms.c linux/net/sunrpc/sunrpc_syms.c
--- v2.4.9/linux/net/sunrpc/sunrpc_syms.c Mon Aug 27 12:41:50 2001
+++ linux/net/sunrpc/sunrpc_syms.c Thu Sep 20 21:02:01 2001
@@ -92,18 +92,11 @@
X EXPORT_SYMBOL(xdr_encode_array);
X EXPORT_SYMBOL(xdr_encode_string);
X EXPORT_SYMBOL(xdr_decode_string);
+EXPORT_SYMBOL(xdr_decode_string_inplace);
X EXPORT_SYMBOL(xdr_decode_netobj);
X EXPORT_SYMBOL(xdr_encode_netobj);
-EXPORT_SYMBOL(xdr_zero);
-EXPORT_SYMBOL(xdr_one);
-EXPORT_SYMBOL(xdr_two);
X EXPORT_SYMBOL(xdr_shift_iovec);
X EXPORT_SYMBOL(xdr_zero_iovec);
-
-/* RPC errors */
-EXPORT_SYMBOL(rpc_success);
-EXPORT_SYMBOL(rpc_garbage_args);
-EXPORT_SYMBOL(rpc_system_err);
X
X /* Debugging symbols */
X #ifdef RPC_DEBUG
diff -u --recursive --new-file v2.4.9/linux/net/sunrpc/svc.c linux/net/sunrpc/svc.c
--- v2.4.9/linux/net/sunrpc/svc.c Tue Jul 3 17:08:22 2001
+++ linux/net/sunrpc/svc.c Fri Sep 7 10:48:39 2001
@@ -31,7 +31,6 @@
X {
X struct svc_serv *serv;
X
- xdr_init();
X #ifdef RPC_DEBUG
X rpc_register_sysctl();
X #endif
diff -u --recursive --new-file v2.4.9/linux/net/sunrpc/xdr.c linux/net/sunrpc/xdr.c
--- v2.4.9/linux/net/sunrpc/xdr.c Sat Apr 1 08:04:27 2000
+++ linux/net/sunrpc/xdr.c Thu Sep 20 21:02:01 2001
@@ -14,41 +14,6 @@
X #include <linux/sunrpc/xdr.h>
X #include <linux/sunrpc/msg_prot.h>
X
-u32 rpc_success, rpc_prog_unavail, rpc_prog_mismatch, rpc_proc_unavail,
- rpc_garbage_args, rpc_system_err;
-u32 rpc_auth_ok, rpc_autherr_badcred, rpc_autherr_rejectedcred,
- rpc_autherr_badverf, rpc_autherr_rejectedverf, rpc_autherr_tooweak;
-u32 xdr_zero, xdr_one, xdr_two;
-
-void
-xdr_init(void)
-{
- static int inited = 0;
-
- if (inited)
- return;
-
- xdr_zero = htonl(0);
- xdr_one = htonl(1);
- xdr_two = htonl(2);
-
- rpc_success = htonl(RPC_SUCCESS);
- rpc_prog_unavail = htonl(RPC_PROG_UNAVAIL);
- rpc_prog_mismatch = htonl(RPC_PROG_MISMATCH);
- rpc_proc_unavail = htonl(RPC_PROC_UNAVAIL);
- rpc_garbage_args = htonl(RPC_GARBAGE_ARGS);
- rpc_system_err = htonl(RPC_SYSTEM_ERR);
-
- rpc_auth_ok = htonl(RPC_AUTH_OK);
- rpc_autherr_badcred = htonl(RPC_AUTH_BADCRED);
- rpc_autherr_rejectedcred = htonl(RPC_AUTH_REJECTEDCRED);
- rpc_autherr_badverf = htonl(RPC_AUTH_BADVERF);
- rpc_autherr_rejectedverf = htonl(RPC_AUTH_REJECTEDVERF);
- rpc_autherr_tooweak = htonl(RPC_AUTH_TOOWEAK);
-
- inited = 1;
-}
-
X /*
X * XDR functions for basic NFS types
X */
@@ -121,6 +86,19 @@
X *sp = string;
X return p + XDR_QUADLEN(len);
X }
+
+u32 *
+xdr_decode_string_inplace(u32 *p, char **sp, int *lenp, int maxlen)
+{
+ unsigned int len;
+
+ if ((len = ntohl(*p++)) > maxlen)
+ return NULL;
+ *lenp = len;
+ *sp = p;
+ return p + XDR_QUADLEN(len);
+}
+
X
X /*
X * Realign the iovec if the server missed out some reply elements
diff -u --recursive --new-file v2.4.9/linux/net/sunrpc/xprt.c linux/net/sunrpc/xprt.c
--- v2.4.9/linux/net/sunrpc/xprt.c Mon Aug 27 12:41:50 2001
+++ linux/net/sunrpc/xprt.c Fri Sep 21 11:24:50 2001
@@ -75,10 +75,6 @@
X * Local variables
X */
X
-/* Spinlock for critical sections in the code. */
-spinlock_t xprt_sock_lock = SPIN_LOCK_UNLOCKED;
-spinlock_t xprt_lock = SPIN_LOCK_UNLOCKED;
-
X #ifdef RPC_DEBUG
X # undef RPC_DEBUG_DATA
X # define RPCDBG_FACILITY RPCDBG_XPRT
@@ -172,6 +168,44 @@
X }
X
X /*
+ * Serialize write access to sockets, in order to prevent different
+ * requests from interfering with each other.
+ * Also prevents TCP socket reconnections from colliding with writes.
+ */
+static int
+xprt_lock_write(struct rpc_xprt *xprt, struct rpc_task *task)
+{
+ int retval;
+ spin_lock_bh(&xprt->sock_lock);
+ if (!xprt->snd_task)
+ xprt->snd_task = task;
+ else if (xprt->snd_task != task) {
+ dprintk("RPC: %4d TCP write queue full (task %d)\n",
+ task->tk_pid, xprt->snd_task->tk_pid);
+ task->tk_timeout = 0;
+ task->tk_status = -EAGAIN;
+ rpc_sleep_on(&xprt->sending, task, NULL, NULL);
+ }
+ retval = xprt->snd_task == task;
+ spin_unlock_bh(&xprt->sock_lock);
+ return retval;
+}
+
+/*
+ * Releases the socket for use by other requests.
+ */
+static void
+xprt_release_write(struct rpc_xprt *xprt, struct rpc_task *task)
+{
+ spin_lock_bh(&xprt->sock_lock);
+ if (xprt->snd_task == task) {
+ xprt->snd_task = NULL;
+ rpc_wake_up_next(&xprt->sending);
+ }
+ spin_unlock_bh(&xprt->sock_lock);
+}
+
+/*
X * Write data to socket.
X */
X static inline int
@@ -285,7 +319,10 @@
X
X if (xprt->nocong)
X return;
- spin_lock_bh(&xprt_sock_lock);
+ /*
+ * Note: we're in a BH context
+ */
+ spin_lock(&xprt->xprt_lock);
X cwnd = xprt->cwnd;
X if (result >= 0) {
X if (xprt->cong < cwnd || time_before(jiffies, xprt->congtime))
@@ -313,7 +350,7 @@
X
X xprt->cwnd = cwnd;
X out:
- spin_unlock_bh(&xprt_sock_lock);
+ spin_unlock(&xprt->xprt_lock);
X }
X
X /*
@@ -394,6 +431,8 @@
X
X /*
X * Reconnect a broken TCP connection.
+ *
+ * Note: This cannot collide with the TCP reads, as both run from rpciod
X */
X void
X xprt_reconnect(struct rpc_task *task)
@@ -416,15 +455,10 @@
X return;
X }
X
- spin_lock(&xprt_lock);
- if (xprt->connecting) {
- task->tk_timeout = 0;
- rpc_sleep_on(&xprt->reconn, task, NULL, NULL);
- spin_unlock(&xprt_lock);
+ if (!xprt_lock_write(xprt, task))
X return;
- }
- xprt->connecting = 1;
- spin_unlock(&xprt_lock);
+ if (xprt_connected(xprt))
+ goto out_write;
X
X status = -ENOTCONN;
X if (!inet) {
@@ -439,6 +473,7 @@
X
X /* Reset TCP record info */
X xprt->tcp_offset = 0;
+ xprt->tcp_reclen = 0;
X xprt->tcp_copied = 0;
X xprt->tcp_more = 0;
X
@@ -467,24 +502,22 @@
X dprintk("RPC: %4d connect status %d connected %d\n",
X task->tk_pid, status, xprt_connected(xprt));
X
- spin_lock_bh(&xprt_sock_lock);
+ spin_lock_bh(&xprt->sock_lock);
X if (!xprt_connected(xprt)) {
X task->tk_timeout = xprt->timeout.to_maxval;
- rpc_sleep_on(&xprt->reconn, task, xprt_reconn_status, NULL);
- spin_unlock_bh(&xprt_sock_lock);
+ rpc_sleep_on(&xprt->sending, task, xprt_reconn_status, NULL);
+ spin_unlock_bh(&xprt->sock_lock);
X return;
X }
- spin_unlock_bh(&xprt_sock_lock);
+ spin_unlock_bh(&xprt->sock_lock);
X }
X defer:
- spin_lock(&xprt_lock);
- xprt->connecting = 0;
X if (status < 0) {
X rpc_delay(task, 5*HZ);
X task->tk_status = -ENOTCONN;
X }
- rpc_wake_up(&xprt->reconn);
- spin_unlock(&xprt_lock);
+ out_write:
+ xprt_release_write(xprt, task);
X }
X
X /*
@@ -499,10 +532,7 @@
X dprintk("RPC: %4d xprt_reconn_timeout %d\n",
X task->tk_pid, task->tk_status);
X
- spin_lock(&xprt_lock);
- xprt->connecting = 0;
- rpc_wake_up(&xprt->reconn);
- spin_unlock(&xprt_lock);
+ xprt_release_write(xprt, task);
X }
X
X /*
@@ -699,10 +729,6 @@
X struct iovec riov;
X int want, result;
X
- if (xprt->tcp_offset >= xprt->tcp_reclen + sizeof(xprt->tcp_recm)) {
- xprt->tcp_offset = 0;
- xprt->tcp_reclen = 0;
- }
X if (xprt->tcp_offset >= sizeof(xprt->tcp_recm))
X goto done;
X
@@ -718,10 +744,6 @@
X want -= result;
X } while (want);
X
- /* Is this another fragment in the last message */
- if (!xprt->tcp_more)
- xprt->tcp_copied = 0; /* No, so we're reading a new message */
-
X /* Get the record length and mask out the last fragment bit */
X xprt->tcp_reclen = ntohl(xprt->tcp_recm);
X xprt->tcp_more = (xprt->tcp_reclen & 0x80000000) ? 0 : 1;
@@ -744,7 +766,7 @@
X
X if (xprt->tcp_copied >= sizeof(xprt->tcp_xid) || !avail)
X goto done;
- want = min(unsigned int, sizeof(xprt->tcp_xid) - xprt->tcp_copied, avail);
+ want = min_t(unsigned int, sizeof(xprt->tcp_xid) - xprt->tcp_copied, avail);
X do {
X dprintk("RPC: reading xid (%d bytes)\n", want);
X riov.iov_base = ((u8*) &xprt->tcp_xid) + xprt->tcp_copied;
@@ -771,7 +793,7 @@
X
X if (req->rq_rlen <= xprt->tcp_copied || !avail)
X goto done;
- want = min(unsigned int, req->rq_rlen - xprt->tcp_copied, avail);
+ want = min_t(unsigned int, req->rq_rlen - xprt->tcp_copied, avail);
X do {
X dprintk("RPC: %4d TCP receiving %d bytes\n",
X req->rq_task->tk_pid, want);
@@ -805,7 +827,7 @@
X int want, result = 0;
X
X while (avail) {
- want = min(unsigned int, avail, sizeof(dummy));
+ want = min_t(unsigned int, avail, sizeof(dummy));
X riov.iov_base = dummy;
X riov.iov_len = want;
X dprintk("RPC: TCP skipping %d bytes\n", want);


@@ -843,14 +865,15 @@
X

X /* Read in a new fragment marker if necessary */
X /* Can we ever really expect to get completely empty fragments? */
- if ((result = tcp_read_fraghdr(xprt)) <= 0)
+ if ((result = tcp_read_fraghdr(xprt)) < 0)
X return result;
X avail = result;
X
X /* Read in the xid if necessary */
- if ((result = tcp_read_xid(xprt, avail)) <= 0)
+ if ((result = tcp_read_xid(xprt, avail)) < 0)
X return result;
- avail = result;
+ if (!(avail = result))
+ goto out_ok;
X
X /* Find and lock the request corresponding to this xid */
X req = xprt_lookup_rqst(xprt, xprt->tcp_xid);
@@ -868,9 +891,14 @@
X if ((result = tcp_read_discard(xprt, avail)) < 0)
X return result;
X
+ out_ok:
X dprintk("RPC: tcp_input_record done (off %d reclen %d copied %d)\n",
X xprt->tcp_offset, xprt->tcp_reclen, xprt->tcp_copied);
X result = xprt->tcp_reclen;
+ xprt->tcp_reclen = 0;
+ xprt->tcp_offset = 0;
+ if (!xprt->tcp_more)
+ xprt->tcp_copied = 0;
X return result;
X }
X
@@ -885,11 +913,19 @@
X rpciod_wake_up();
X }
X
+int xprt_tcp_pending(void)
+{
+ int retval;
+
+ spin_lock_bh(&rpc_queue_lock);
+ retval = !list_empty(&rpc_xprt_pending);
+ spin_unlock_bh(&rpc_queue_lock);
+ return retval;
+}
+
X static inline
X void xprt_append_pending(struct rpc_xprt *xprt)
X {
- if (!list_empty(&xprt->rx_pending))
- return;
X spin_lock_bh(&rpc_queue_lock);
X if (list_empty(&xprt->rx_pending)) {
X list_add(&xprt->rx_pending, rpc_xprt_pending.prev);
@@ -1003,11 +1039,10 @@
X case TCP_ESTABLISHED:
X if (xprt_test_and_set_connected(xprt))
X break;
- spin_lock_bh(&xprt_sock_lock);
+ spin_lock(&xprt->sock_lock);
X if (xprt->snd_task && xprt->snd_task->tk_rpcwait == &xprt->sending)
X rpc_wake_up_task(xprt->snd_task);
- rpc_wake_up(&xprt->reconn);
- spin_unlock_bh(&xprt_sock_lock);
+ spin_unlock(&xprt->sock_lock);
X break;
X case TCP_SYN_SENT:
X case TCP_SYN_RECV:
@@ -1041,10 +1076,10 @@
X return;
X
X if (!xprt_test_and_set_wspace(xprt)) {
- spin_lock_bh(&xprt_sock_lock);
+ spin_lock(&xprt->sock_lock);
X if (xprt->snd_task && xprt->snd_task->tk_rpcwait == &xprt->sending)
X rpc_wake_up_task(xprt->snd_task);
- spin_unlock_bh(&xprt_sock_lock);
+ spin_unlock(&xprt->sock_lock);
X }
X
X if (test_bit(SOCK_NOSPACE, &sock->flags)) {
@@ -1067,14 +1102,14 @@
X
X
X /* Wait until we have enough socket memory */
- if (sock_wspace(sk) < min(int, sk->sndbuf,XPRT_MIN_WRITE_SPACE))
+ if (sock_wspace(sk) < min_t(int, sk->sndbuf,XPRT_MIN_WRITE_SPACE))
X return;
X
X if (!xprt_test_and_set_wspace(xprt)) {
- spin_lock_bh(&xprt_sock_lock);
+ spin_lock(&xprt->sock_lock);
X if (xprt->snd_task && xprt->snd_task->tk_rpcwait == &xprt->sending)
X rpc_wake_up_task(xprt->snd_task);
- spin_unlock_bh(&xprt_sock_lock);
+ spin_unlock(&xprt->sock_lock);
X }
X
X if (sk->sleep && waitqueue_active(sk->sleep))
@@ -1100,55 +1135,6 @@
X rpc_wake_up_task(task);
X }
X
-
-/*
- * Serialize access to sockets, in order to prevent different
- * requests from interfering with each other.
- */
-static int
-xprt_down_transmit(struct rpc_task *task)
-{
- struct rpc_xprt *xprt = task->tk_rqstp->rq_xprt;
- struct rpc_rqst *req = task->tk_rqstp;
-
- spin_lock_bh(&xprt_sock_lock);
- spin_lock(&xprt_lock);
- if (xprt->snd_task && xprt->snd_task != task) {
- dprintk("RPC: %4d TCP write queue full (task %d)\n",
- task->tk_pid, xprt->snd_task->tk_pid);
- task->tk_timeout = 0;
- task->tk_status = -EAGAIN;
- rpc_sleep_on(&xprt->sending, task, NULL, NULL);
- } else if (!xprt->snd_task) {
- xprt->snd_task = task;
-#ifdef RPC_PROFILE
- req->rq_xtime = jiffies;
-#endif
- req->rq_bytes_sent = 0;
- }
- spin_unlock(&xprt_lock);
- spin_unlock_bh(&xprt_sock_lock);
- return xprt->snd_task == task;
-}
-
-/*
- * Releases the socket for use by other requests.
- */
-static inline void
-xprt_up_transmit(struct rpc_task *task)
-{
- struct rpc_xprt *xprt = task->tk_rqstp->rq_xprt;
-
- if (xprt->snd_task && xprt->snd_task == task) {
- spin_lock_bh(&xprt_sock_lock);
- spin_lock(&xprt_lock);
- xprt->snd_task = NULL;
- rpc_wake_up_next(&xprt->sending);
- spin_unlock(&xprt_lock);
- spin_unlock_bh(&xprt_sock_lock);
- }
-}
-
X /*
X * Place the actual RPC call.
X * We have to copy the iovec because sendmsg fiddles with its contents.
@@ -1182,9 +1168,12 @@
X *marker = htonl(0x80000000|(req->rq_slen-sizeof(*marker)));
X }
X
- if (!xprt_down_transmit(task))
+ if (!xprt_lock_write(xprt, task))
X return;
X
+#ifdef RPC_PROFILE
+ req->rq_xtime = jiffies;
+#endif
X do_xprt_transmit(task);
X }
X
@@ -1252,12 +1241,12 @@
X switch (status) {
X case -ENOMEM:
X /* Protect against (udp|tcp)_write_space */
- spin_lock_bh(&xprt_sock_lock);
+ spin_lock_bh(&xprt->sock_lock);
X if (!xprt_wspace(xprt)) {
X task->tk_timeout = req->rq_timeout.to_current;
X rpc_sleep_on(&xprt->sending, task, NULL, NULL);
X }
- spin_unlock_bh(&xprt_sock_lock);
+ spin_unlock_bh(&xprt->sock_lock);
X return;
X case -EAGAIN:
X /* Keep holding the socket if it is blocked */
@@ -1268,6 +1257,9 @@
X if (!xprt->stream)
X return;
X default:
+ if (xprt->stream)
+ xprt_disconnect(xprt);
+ req->rq_bytes_sent = 0;
X goto out_release;
X }
X
@@ -1278,7 +1270,7 @@
X rpc_add_timer(task, xprt_timer);
X rpc_unlock_task(task);
X out_release:
- xprt_up_transmit(task);
+ xprt_release_write(xprt, task);
X }
X
X /*
@@ -1313,7 +1305,7 @@
X
X dprintk("RPC: %4d xprt_reserve cong = %ld cwnd = %ld\n",
X task->tk_pid, xprt->cong, xprt->cwnd);
- spin_lock_bh(&xprt_sock_lock);
+ spin_lock_bh(&xprt->xprt_lock);
X xprt_reserve_status(task);
X if (task->tk_rqstp) {
X task->tk_timeout = 0;
@@ -1324,7 +1316,7 @@
X task->tk_status = -EAGAIN;
X rpc_sleep_on(&xprt->backlog, task, NULL, NULL);
X }
- spin_unlock_bh(&xprt_sock_lock);
+ spin_unlock_bh(&xprt->xprt_lock);
X dprintk("RPC: %4d xprt_reserve returns %d\n",
X task->tk_pid, task->tk_status);
X return task->tk_status;
@@ -1397,7 +1389,11 @@
X struct rpc_xprt *xprt = task->tk_xprt;
X struct rpc_rqst *req;
X
- xprt_up_transmit(task);
+ if (xprt->snd_task == task) {
+ if (xprt->stream)
+ xprt_disconnect(xprt);
+ xprt_release_write(xprt, task);
+ }
X if (!(req = task->tk_rqstp))
X return;
X task->tk_rqstp = NULL;
@@ -1411,7 +1407,7 @@
X rpc_remove_wait_queue(task);
X }
X
- spin_lock_bh(&xprt_sock_lock);
+ spin_lock_bh(&xprt->xprt_lock);
X req->rq_next = xprt->free;
X xprt->free = req;
X
@@ -1419,7 +1415,7 @@
X xprt->cong -= RPC_CWNDSCALE;
X
X xprt_clear_backlog(xprt);
- spin_unlock_bh(&xprt_sock_lock);
+ spin_unlock_bh(&xprt->xprt_lock);
X }
X
X /*
@@ -1476,6 +1472,8 @@
X } else
X xprt->cwnd = RPC_INITCWND;
X xprt->congtime = jiffies;
+ spin_lock_init(&xprt->sock_lock);
+ spin_lock_init(&xprt->xprt_lock);
X init_waitqueue_head(&xprt->cong_wait);
X
X /* Set timeout parameters */
@@ -1489,7 +1487,6 @@
X xprt->pending = RPC_INIT_WAITQ("xprt_pending");
X xprt->sending = RPC_INIT_WAITQ("xprt_sending");
X xprt->backlog = RPC_INIT_WAITQ("xprt_backlog");
- xprt->reconn = RPC_INIT_WAITQ("xprt_reconn");
X
X /* initialize free list */
X for (i = 0, req = xprt->slot; i < RPC_MAXREQS-1; i++, req++)
@@ -1625,7 +1622,6 @@
X rpc_wake_up(&xprt->sending);
X rpc_wake_up(&xprt->pending);
X rpc_wake_up(&xprt->backlog);
- rpc_wake_up(&xprt->reconn);
X if (waitqueue_active(&xprt->cong_wait))
X wake_up(&xprt->cong_wait);
X }
diff -u --recursive --new-file v2.4.9/linux/net/unix/af_unix.c linux/net/unix/af_unix.c
--- v2.4.9/linux/net/unix/af_unix.c Mon Aug 27 12:41:50 2001
+++ linux/net/unix/af_unix.c Thu Sep 20 14:12:56 2001
@@ -8,7 +8,7 @@


X * as published by the Free Software Foundation; either version
X * 2 of the License, or (at your option) any later version.

X *
- * Version: $Id: af_unix.c,v 1.121 2001/08/13 18:56:13 davem Exp $
+ * Version: $Id: af_unix.c,v 1.123 2001/09/19 04:50:32 davem Exp $


X *
X * Fixes:

X * Linus Torvalds : Assorted bug cures.
@@ -1336,7 +1336,7 @@
X * fallback size buffer which is under a page and will
X * succeed. [Alan]
X */
- size = min(int, size, skb_tailroom(skb));
+ size = min_t(int, size, skb_tailroom(skb));
X
X memcpy(UNIXCREDS(skb), &scm->creds, sizeof(struct ucred));
X if (scm->fp)
@@ -1568,7 +1568,7 @@
X sunaddr = NULL;


X }
X
- chunk = min(unsigned int, skb->len, size);
+ chunk = min_t(unsigned int, skb->len, size);
X if (memcpy_toiovec(msg->msg_iov, skb->data, chunk)) {
X skb_queue_head(&sk->receive_queue, skb);
X if (copied == 0)

@@ -1845,7 +1845,7 @@
X static inline void unix_sysctl_unregister(void) {}
X #endif
X
-static const char banner[] __initdata = KERN_INFO "NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.\n";
+static char banner[] __initdata = KERN_INFO "NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.\n";
X
X static int __init af_unix_init(void)
X {
diff -u --recursive --new-file v2.4.9/linux/net/wanrouter/wanproc.c linux/net/wanrouter/wanproc.c
--- v2.4.9/linux/net/wanrouter/wanproc.c Mon Aug 27 12:41:50 2001
+++ linux/net/wanrouter/wanproc.c Mon Sep 10 07:58:35 2001
@@ -259,7 +259,7 @@
X pos = dent->get_info(page, dent->data, 0, 0);
X offs = file->f_pos;
X if (offs < pos) {
- len = min(unsigned int, pos - offs, count);
+ len = min_t(unsigned int, pos - offs, count);
X if (copy_to_user(buf, (page + offs), len)) {
X kfree(page);
X return -EFAULT;
@@ -805,7 +805,7 @@
X pos = dent->get_info(page, dent->data, 0, 0, 0);
X offs = file->f_pos;
X if (offs < pos) {
- len = min(unsigned int, pos - offs, count);
+ len = min_t(unsigned int, pos - offs, count);
X if (copy_to_user(buf, (page + offs), len)) {
X kfree(page);
X return -EFAULT;
@@ -841,7 +841,7 @@
X pos = dent->get_info(page, dent->data, 0, 0, 0);
X offs = file->f_pos;
X if (offs < pos) {
- len = min(unsigned int, pos - offs, count);
+ len = min_t(unsigned int, pos - offs, count);
X memcpy_tofs((void*)buf, (void*)(page + offs), len);
X file->f_pos += len;
X }
diff -u --recursive --new-file v2.4.9/linux/net/x25/af_x25.c linux/net/x25/af_x25.c
--- v2.4.9/linux/net/x25/af_x25.c Mon Aug 27 12:41:50 2001
+++ linux/net/x25/af_x25.c Mon Sep 10 07:58:35 2001
@@ -407,7 +407,7 @@


X return -ENOPROTOOPT;
X }
X
- len = min(unsigned int, len, sizeof(int));
+ len = min_t(unsigned int, len, sizeof(int));
X

X if (len < 0)
X return -EINVAL;
diff -u --recursive --new-file v2.4.9/linux/scripts/mkdep.c linux/scripts/mkdep.c
--- v2.4.9/linux/scripts/mkdep.c Fri Mar 2 11:12:12 2001
+++ linux/scripts/mkdep.c Fri Sep 14 14:40:00 2001
@@ -291,7 +291,7 @@
X * Thus, there is one memory access per sizeof(unsigned long) characters.
X */
X
-#if defined(__alpha__) || defined(__i386__) || defined(__ia64__) || defined(__MIPSEL__) \
+#if defined(__alpha__) || defined(__i386__) || defined(__ia64__) || defined(__x86_64__) || defined(__MIPSEL__) \
X || defined(__arm__)
X #define LE_MACHINE
X #endif
diff -u --recursive --new-file v2.4.9/linux/scripts/mkspec linux/scripts/mkspec
--- v2.4.9/linux/scripts/mkspec Wed Dec 31 16:00:00 1969
+++ linux/scripts/mkspec Mon Sep 17 23:04:05 2001
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# Output a simple RPM spec file that uses no fancy features requring
+# RPM v4. This is intended to work with any RPM distro.
+#
+# The only gothic bit here is redefining install_post to avoid
+# stripping the symbols from files in the kernel which we want
+#
+echo "Name: kernel"
+echo "Summary: The Linux Kernel"
+echo "Version: "$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION | sed -e "s/-//"
+# we need to determine the NEXT version number so that uname and
+# rpm -q will agree
+echo "Release: `. scripts/mkversion`"
+echo "License: GPL"
+echo "Group: System Environment/Kernel"
+echo "Vendor: The Linux Community"
+echo "URL: http://www.kernel.org"
+echo -n "Source: kernel-$VERSION.$PATCHLEVEL.$SUBLEVEL"
+echo "$EXTRAVERSION.tar.gz" | sed -e "s/-//"
+echo "BuildRoot: /var/tmp/%{name}-%{PACKAGE_VERSION}-root"
+echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :"
+echo ""
+echo "%description"
+echo "The Linux Kernel, the operating system core itself"
+echo ""
+echo "%prep"
+echo "%setup -q"
+echo ""
+echo "%build"
+echo "make oldconfig dep clean bzImage modules"
+echo ""
+echo "%install"
+echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib $RPM_BUILD_ROOT/lib/modules'
+echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make modules_install'
+echo 'cp arch/i386/boot/bzImage $RPM_BUILD_ROOT'"/boot/vmlinuz-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
+echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
+echo ""
+echo "%clean"
+echo '#echo -rf $RPM_BUILD_ROOT'
+echo ""
+echo "%files"
+echo '%defattr (-, root, root)'
+echo "%dir /lib/modules"
+echo "/lib/modules/$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
+echo "/boot/*"
+echo ""
diff -u --recursive --new-file v2.4.9/linux/scripts/mkversion linux/scripts/mkversion
--- v2.4.9/linux/scripts/mkversion Wed Dec 31 16:00:00 1969
+++ linux/scripts/mkversion Mon Sep 17 23:04:05 2001
@@ -0,0 +1,6 @@
+if [ ! -f .version ]
+then
+ echo 1
+else
+ expr 0`cat .version` + 1
+fi
diff -u --recursive --new-file v2.4.9/linux/scripts/ver_linux linux/scripts/ver_linux
--- v2.4.9/linux/scripts/ver_linux Thu Apr 12 12:16:36 2001
+++ linux/scripts/ver_linux Sun Sep 2 07:27:18 2001
@@ -26,7 +26,7 @@
X
X insmod -V 2>&1 | awk 'NR==1 {print "modutils ",$NF}'
X
-tune2fs 2>&1 | grep tune2fs | sed 's/,//' | awk \
+tune2fs 2>&1 | grep "^tune2fs" | sed 's/,//' | awk \
X 'NR==1 {print "e2fsprogs ", $2}'
X
X reiserfsck 2>&1 | grep reiserfsprogs | awk \
@@ -66,5 +66,7 @@
X
X expr --v 2>&1 | awk 'NR==1{print "Sh-utils ", $NF}'
X
-X=`cat /proc/modules | sed -e "s/ .*$//"`
-echo "Modules Loaded "$X
+if [ -e /proc/modules ]; then
+ X=`cat /proc/modules | sed -e "s/ .*$//"`
+ echo "Modules Loaded "$X
+fi


SHAR_EOF
true || echo 'restore of patch-2.4.10 failed'

echo 'File patch-2.4.10 is complete' &&
chmod 644 patch-2.4.10 ||


echo 'restore of patch-2.4.10 failed'

Cksum="`cksum < 'patch-2.4.10'`"
if ! test "3939294859 11310868" = "$Cksum" ; then
echo 'patch-2.4.10: original Checksum 3939294859 11310868, current one' "$Cksum"
rm -f _shar_wnt_.tmp
rm -f _shar_seq_.tmp
exit 1
fi
rm -f _shar_wnt_.tmp
fi
rm -f _shar_seq_.tmp
echo 'You have unpacked the last part.'
exit 0

0 new messages