ng_l2tp.c (140064) | ng_l2tp.c (148915) |
---|---|
1/*- 2 * Copyright (c) 2001-2002 Packet Design, LLC. 3 * All rights reserved. 4 * 5 * Subject to the following obligations and disclaimer of warranty, 6 * use and redistribution of this software, in source or object code 7 * forms, with or without modifications are expressly permitted by 8 * Packet Design; provided, however, that: --- 22 unchanged lines hidden (view full) --- 31 * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF 32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 34 * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF 35 * THE POSSIBILITY OF SUCH DAMAGE. 36 * 37 * Author: Archie Cobbs <archie@freebsd.org> 38 * | 1/*- 2 * Copyright (c) 2001-2002 Packet Design, LLC. 3 * All rights reserved. 4 * 5 * Subject to the following obligations and disclaimer of warranty, 6 * use and redistribution of this software, in source or object code 7 * forms, with or without modifications are expressly permitted by 8 * Packet Design; provided, however, that: --- 22 unchanged lines hidden (view full) --- 31 * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF 32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 34 * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF 35 * THE POSSIBILITY OF SUCH DAMAGE. 36 * 37 * Author: Archie Cobbs <archie@freebsd.org> 38 * |
39 * $FreeBSD: head/sys/netgraph/ng_l2tp.c 140064 2005-01-11 11:51:17Z glebius $ | 39 * $FreeBSD: head/sys/netgraph/ng_l2tp.c 148915 2005-08-10 06:25:41Z obrien $ |
40 */ 41 42/* 43 * L2TP netgraph node type. 44 * 45 * This node type implements the lower layer of the 46 * L2TP protocol as specified in RFC 2661. 47 */ --- 996 unchanged lines hidden (view full) --- 1044 m_freem(m); 1045 return (ENOBUFS); 1046 } 1047 seq->xwin[i] = m; 1048 1049 /* Sanity check receive ack timer state */ 1050 KASSERT((i == 0) ^ callout_pending(&seq->rack_timer), 1051 ("%s: xwin %d full but rack timer %s running", | 40 */ 41 42/* 43 * L2TP netgraph node type. 44 * 45 * This node type implements the lower layer of the 46 * L2TP protocol as specified in RFC 2661. 47 */ --- 996 unchanged lines hidden (view full) --- 1044 m_freem(m); 1045 return (ENOBUFS); 1046 } 1047 seq->xwin[i] = m; 1048 1049 /* Sanity check receive ack timer state */ 1050 KASSERT((i == 0) ^ callout_pending(&seq->rack_timer), 1051 ("%s: xwin %d full but rack timer %s running", |
1052 __FUNCTION__, i, callout_pending(&seq->rack_timer) ? "" : "not ")); | 1052 __func__, i, callout_pending(&seq->rack_timer) ? "" : "not ")); |
1053 1054 /* If peer's receive window is already full, nothing else to do */ 1055 if (i >= seq->cwnd) 1056 return (0); 1057 1058 /* Start retransmit timer if not already running */ 1059 if (!callout_pending(&seq->rack_timer)) 1060 ng_callout(&seq->rack_timer, node, NULL, --- 89 unchanged lines hidden (view full) --- 1150 * Initialize sequence number state. 1151 */ 1152static void 1153ng_l2tp_seq_init(priv_p priv) 1154{ 1155 struct l2tp_seq *const seq = &priv->seq; 1156 1157 KASSERT(priv->conf.peer_win >= 1, | 1053 1054 /* If peer's receive window is already full, nothing else to do */ 1055 if (i >= seq->cwnd) 1056 return (0); 1057 1058 /* Start retransmit timer if not already running */ 1059 if (!callout_pending(&seq->rack_timer)) 1060 ng_callout(&seq->rack_timer, node, NULL, --- 89 unchanged lines hidden (view full) --- 1150 * Initialize sequence number state. 1151 */ 1152static void 1153ng_l2tp_seq_init(priv_p priv) 1154{ 1155 struct l2tp_seq *const seq = &priv->seq; 1156 1157 KASSERT(priv->conf.peer_win >= 1, |
1158 ("%s: peer_win is zero", __FUNCTION__)); | 1158 ("%s: peer_win is zero", __func__)); |
1159 memset(seq, 0, sizeof(*seq)); 1160 seq->cwnd = 1; 1161 seq->wmax = priv->conf.peer_win; 1162 if (seq->wmax > L2TP_MAX_XWIN) 1163 seq->wmax = L2TP_MAX_XWIN; 1164 seq->ssth = seq->wmax; 1165 seq->max_rexmits = priv->conf.rexmit_max; 1166 seq->max_rexmit_to = priv->conf.rexmit_max_to; --- 111 unchanged lines hidden (view full) --- 1278 /* Verify peer's ACK is in range */ 1279 if ((nack = L2TP_SEQ_DIFF(nr, seq->rack)) <= 0) 1280 return; /* duplicate ack */ 1281 if (L2TP_SEQ_DIFF(nr, seq->ns) > 0) { 1282 priv->stats.recvBadAcks++; /* ack for packet not sent */ 1283 return; 1284 } 1285 KASSERT(nack <= L2TP_MAX_XWIN, | 1159 memset(seq, 0, sizeof(*seq)); 1160 seq->cwnd = 1; 1161 seq->wmax = priv->conf.peer_win; 1162 if (seq->wmax > L2TP_MAX_XWIN) 1163 seq->wmax = L2TP_MAX_XWIN; 1164 seq->ssth = seq->wmax; 1165 seq->max_rexmits = priv->conf.rexmit_max; 1166 seq->max_rexmit_to = priv->conf.rexmit_max_to; --- 111 unchanged lines hidden (view full) --- 1278 /* Verify peer's ACK is in range */ 1279 if ((nack = L2TP_SEQ_DIFF(nr, seq->rack)) <= 0) 1280 return; /* duplicate ack */ 1281 if (L2TP_SEQ_DIFF(nr, seq->ns) > 0) { 1282 priv->stats.recvBadAcks++; /* ack for packet not sent */ 1283 return; 1284 } 1285 KASSERT(nack <= L2TP_MAX_XWIN, |
1286 ("%s: nack=%d > %d", __FUNCTION__, nack, L2TP_MAX_XWIN)); | 1286 ("%s: nack=%d > %d", __func__, nack, L2TP_MAX_XWIN)); |
1287 1288 /* Update receive ack stats */ 1289 seq->rack = nr; 1290 seq->rexmits = 0; 1291 1292 /* Free acknowledged packets and shift up packets in the xmit queue */ 1293 for (i = 0; i < nack; i++) 1294 m_freem(seq->xwin[i]); --- 233 unchanged lines hidden (view full) --- 1528 */ 1529static void 1530ng_l2tp_seq_check(struct l2tp_seq *seq) 1531{ 1532 const int self_unack = L2TP_SEQ_DIFF(seq->nr, seq->xack); 1533 const int peer_unack = L2TP_SEQ_DIFF(seq->ns, seq->rack); 1534 int i; 1535 | 1287 1288 /* Update receive ack stats */ 1289 seq->rack = nr; 1290 seq->rexmits = 0; 1291 1292 /* Free acknowledged packets and shift up packets in the xmit queue */ 1293 for (i = 0; i < nack; i++) 1294 m_freem(seq->xwin[i]); --- 233 unchanged lines hidden (view full) --- 1528 */ 1529static void 1530ng_l2tp_seq_check(struct l2tp_seq *seq) 1531{ 1532 const int self_unack = L2TP_SEQ_DIFF(seq->nr, seq->xack); 1533 const int peer_unack = L2TP_SEQ_DIFF(seq->ns, seq->rack); 1534 int i; 1535 |
1536#define CHECK(p) KASSERT((p), ("%s: not: %s", __FUNCTION__, #p)) | 1536#define CHECK(p) KASSERT((p), ("%s: not: %s", __func__, #p)) |
1537 1538 CHECK(seq->wmax <= L2TP_MAX_XWIN); 1539 CHECK(seq->cwnd >= 1); 1540 CHECK(seq->cwnd <= seq->wmax); 1541 CHECK(seq->ssth >= 1); 1542 CHECK(seq->ssth <= seq->wmax); 1543 if (seq->cwnd < seq->ssth) 1544 CHECK(seq->acks == 0); --- 15 unchanged lines hidden --- | 1537 1538 CHECK(seq->wmax <= L2TP_MAX_XWIN); 1539 CHECK(seq->cwnd >= 1); 1540 CHECK(seq->cwnd <= seq->wmax); 1541 CHECK(seq->ssth >= 1); 1542 CHECK(seq->ssth <= seq->wmax); 1543 if (seq->cwnd < seq->ssth) 1544 CHECK(seq->acks == 0); --- 15 unchanged lines hidden --- |