ng_l2tp.c (108107) | ng_l2tp.c (109623) |
---|---|
1 2/* 3 * Copyright (c) 2001-2002 Packet Design, LLC. 4 * All rights reserved. 5 * 6 * Subject to the following obligations and disclaimer of warranty, 7 * use and redistribution of this software, in source or object code 8 * forms, with or without modifications are expressly permitted by --- 23 unchanged lines hidden (view full) --- 32 * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF 33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 35 * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF 36 * THE POSSIBILITY OF SUCH DAMAGE. 37 * 38 * Author: Archie Cobbs <archie@freebsd.org> 39 * | 1 2/* 3 * Copyright (c) 2001-2002 Packet Design, LLC. 4 * All rights reserved. 5 * 6 * Subject to the following obligations and disclaimer of warranty, 7 * use and redistribution of this software, in source or object code 8 * forms, with or without modifications are expressly permitted by --- 23 unchanged lines hidden (view full) --- 32 * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF 33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 35 * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF 36 * THE POSSIBILITY OF SUCH DAMAGE. 37 * 38 * Author: Archie Cobbs <archie@freebsd.org> 39 * |
40 * $FreeBSD: head/sys/netgraph/ng_l2tp.c 108107 2002-12-19 22:58:27Z bmilekic $ | 40 * $FreeBSD: head/sys/netgraph/ng_l2tp.c 109623 2003-01-21 08:56:16Z alfred $ |
41 */ 42 43/* 44 * L2TP netgraph node type. 45 * 46 * This node type implements the lower layer of the 47 * L2TP protocol as specified in RFC 2661. 48 */ --- 797 unchanged lines hidden (view full) --- 846 } 847 848 /* 849 * Prepend session ID to packet here: we don't want to accept 850 * the send sequence number Ns if we have to drop the packet 851 * later because of a memory error, because then the upper 852 * layer would never get the packet. 853 */ | 41 */ 42 43/* 44 * L2TP netgraph node type. 45 * 46 * This node type implements the lower layer of the 47 * L2TP protocol as specified in RFC 2661. 48 */ --- 797 unchanged lines hidden (view full) --- 846 } 847 848 /* 849 * Prepend session ID to packet here: we don't want to accept 850 * the send sequence number Ns if we have to drop the packet 851 * later because of a memory error, because then the upper 852 * layer would never get the packet. 853 */ |
854 M_PREPEND(m, 2, M_DONTWAIT); | 854 M_PREPEND(m, 2, M_NOWAIT); |
855 if (m == NULL) { 856 priv->stats.memoryFailures++; 857 NG_FREE_ITEM(item); 858 return (ENOBUFS); 859 } 860 memcpy(mtod(m, u_int16_t *), &ids[1], 2); 861 862 /* Now handle send sequence number */ --- 87 unchanged lines hidden (view full) --- 950 if (!seq->rack_timer_running) { 951 callout_reset(&seq->rack_timer, 952 hz, ng_l2tp_seq_rack_timeout, node); 953 seq->rack_timer_running = 1; 954 NG_NODE_REF(node); 955 } 956 957 /* Copy packet */ | 855 if (m == NULL) { 856 priv->stats.memoryFailures++; 857 NG_FREE_ITEM(item); 858 return (ENOBUFS); 859 } 860 memcpy(mtod(m, u_int16_t *), &ids[1], 2); 861 862 /* Now handle send sequence number */ --- 87 unchanged lines hidden (view full) --- 950 if (!seq->rack_timer_running) { 951 callout_reset(&seq->rack_timer, 952 hz, ng_l2tp_seq_rack_timeout, node); 953 seq->rack_timer_running = 1; 954 NG_NODE_REF(node); 955 } 956 957 /* Copy packet */ |
958 if ((m = L2TP_COPY_MBUF(seq->xwin[i], M_DONTWAIT)) == NULL) { | 958 if ((m = L2TP_COPY_MBUF(seq->xwin[i], M_NOWAIT)) == NULL) { |
959 priv->stats.memoryFailures++; 960 return (ENOBUFS); 961 } 962 963 /* Send packet and increment xmit sequence number */ 964 return (ng_l2tp_xmit_ctrl(priv, m, seq->ns++)); 965} 966 --- 19 unchanged lines hidden (view full) --- 986 NG_FREE_M(m); 987 return (EOVERFLOW); 988 } 989 990 /* Prepend L2TP header */ 991 M_PREPEND(m, 6 992 + (2 * (hpriv->conf.include_length != 0)) 993 + (4 * (hpriv->conf.enable_dseq != 0)), | 959 priv->stats.memoryFailures++; 960 return (ENOBUFS); 961 } 962 963 /* Send packet and increment xmit sequence number */ 964 return (ng_l2tp_xmit_ctrl(priv, m, seq->ns++)); 965} 966 --- 19 unchanged lines hidden (view full) --- 986 NG_FREE_M(m); 987 return (EOVERFLOW); 988 } 989 990 /* Prepend L2TP header */ 991 M_PREPEND(m, 6 992 + (2 * (hpriv->conf.include_length != 0)) 993 + (4 * (hpriv->conf.enable_dseq != 0)), |
994 M_DONTWAIT); | 994 M_NOWAIT); |
995 if (m == NULL) { 996 priv->stats.memoryFailures++; 997 NG_FREE_ITEM(item); 998 return (ENOBUFS); 999 } 1000 hdr = L2TP_DATA_HDR; 1001 if (hpriv->conf.include_length) { 1002 hdr |= L2TP_HDR_LEN; --- 211 unchanged lines hidden (view full) --- 1214 1215 /* 1216 * Send more packets, trying to keep peer's receive window full. 1217 * If there is a memory error, pretend packet was sent, as it 1218 * will get retransmitted later anyway. 1219 */ 1220 while ((i = L2TP_SEQ_DIFF(seq->ns, seq->rack)) < seq->cwnd 1221 && seq->xwin[i] != NULL) { | 995 if (m == NULL) { 996 priv->stats.memoryFailures++; 997 NG_FREE_ITEM(item); 998 return (ENOBUFS); 999 } 1000 hdr = L2TP_DATA_HDR; 1001 if (hpriv->conf.include_length) { 1002 hdr |= L2TP_HDR_LEN; --- 211 unchanged lines hidden (view full) --- 1214 1215 /* 1216 * Send more packets, trying to keep peer's receive window full. 1217 * If there is a memory error, pretend packet was sent, as it 1218 * will get retransmitted later anyway. 1219 */ 1220 while ((i = L2TP_SEQ_DIFF(seq->ns, seq->rack)) < seq->cwnd 1221 && seq->xwin[i] != NULL) { |
1222 if ((m = L2TP_COPY_MBUF(seq->xwin[i], M_DONTWAIT)) == NULL) | 1222 if ((m = L2TP_COPY_MBUF(seq->xwin[i], M_NOWAIT)) == NULL) |
1223 priv->stats.memoryFailures++; 1224 else 1225 ng_l2tp_xmit_ctrl(priv, m, seq->ns); 1226 seq->ns++; 1227 } 1228} 1229 1230/* --- 125 unchanged lines hidden (view full) --- 1356 hz * delay, ng_l2tp_seq_rack_timeout, node); 1357 1358 /* Do slow-start/congestion algorithm windowing algorithm */ 1359 seq->ssth = (seq->cwnd + 1) / 2; 1360 seq->cwnd = 1; 1361 seq->acks = 0; 1362 1363 /* Retransmit oldest unack'd packet */ | 1223 priv->stats.memoryFailures++; 1224 else 1225 ng_l2tp_xmit_ctrl(priv, m, seq->ns); 1226 seq->ns++; 1227 } 1228} 1229 1230/* --- 125 unchanged lines hidden (view full) --- 1356 hz * delay, ng_l2tp_seq_rack_timeout, node); 1357 1358 /* Do slow-start/congestion algorithm windowing algorithm */ 1359 seq->ssth = (seq->cwnd + 1) / 2; 1360 seq->cwnd = 1; 1361 seq->acks = 0; 1362 1363 /* Retransmit oldest unack'd packet */ |
1364 if ((m = L2TP_COPY_MBUF(seq->xwin[0], M_DONTWAIT)) == NULL) | 1364 if ((m = L2TP_COPY_MBUF(seq->xwin[0], M_NOWAIT)) == NULL) |
1365 priv->stats.memoryFailures++; 1366 else 1367 ng_l2tp_xmit_ctrl(priv, m, seq->rack); 1368 1369done: 1370 /* Done */ 1371 L2TP_SEQ_CHECK(seq); 1372 splx(s); --- 10 unchanged lines hidden (view full) --- 1383 u_int16_t session_id = 0; 1384 meta_p meta = NULL; 1385 int error; 1386 1387 /* If no mbuf passed, send an empty packet (ZLB) */ 1388 if (m == NULL) { 1389 1390 /* Create a new mbuf for ZLB packet */ | 1365 priv->stats.memoryFailures++; 1366 else 1367 ng_l2tp_xmit_ctrl(priv, m, seq->rack); 1368 1369done: 1370 /* Done */ 1371 L2TP_SEQ_CHECK(seq); 1372 splx(s); --- 10 unchanged lines hidden (view full) --- 1383 u_int16_t session_id = 0; 1384 meta_p meta = NULL; 1385 int error; 1386 1387 /* If no mbuf passed, send an empty packet (ZLB) */ 1388 if (m == NULL) { 1389 1390 /* Create a new mbuf for ZLB packet */ |
1391 MGETHDR(m, M_DONTWAIT, MT_DATA); | 1391 MGETHDR(m, M_NOWAIT, MT_DATA); |
1392 if (m == NULL) { 1393 priv->stats.memoryFailures++; 1394 return (ENOBUFS); 1395 } 1396 m->m_len = m->m_pkthdr.len = 12; 1397 m->m_pkthdr.rcvif = NULL; 1398 priv->stats.xmitZLBs++; 1399 } else { 1400 1401 /* Strip off session ID */ 1402 if (m->m_len < 2 && (m = m_pullup(m, 2)) == NULL) { 1403 priv->stats.memoryFailures++; 1404 return (ENOBUFS); 1405 } 1406 memcpy(&session_id, mtod(m, u_int16_t *), 2); 1407 m_adj(m, 2); 1408 1409 /* Make room for L2TP header */ | 1392 if (m == NULL) { 1393 priv->stats.memoryFailures++; 1394 return (ENOBUFS); 1395 } 1396 m->m_len = m->m_pkthdr.len = 12; 1397 m->m_pkthdr.rcvif = NULL; 1398 priv->stats.xmitZLBs++; 1399 } else { 1400 1401 /* Strip off session ID */ 1402 if (m->m_len < 2 && (m = m_pullup(m, 2)) == NULL) { 1403 priv->stats.memoryFailures++; 1404 return (ENOBUFS); 1405 } 1406 memcpy(&session_id, mtod(m, u_int16_t *), 2); 1407 m_adj(m, 2); 1408 1409 /* Make room for L2TP header */ |
1410 M_PREPEND(m, 12, M_DONTWAIT); | 1410 M_PREPEND(m, 12, M_NOWAIT); |
1411 if (m == NULL) { 1412 priv->stats.memoryFailures++; 1413 return (ENOBUFS); 1414 } 1415 } 1416 1417 /* Fill in L2TP header */ 1418 mtod(m, u_int16_t *)[0] = htons(L2TP_CTRL_HDR); --- 61 unchanged lines hidden --- | 1411 if (m == NULL) { 1412 priv->stats.memoryFailures++; 1413 return (ENOBUFS); 1414 } 1415 } 1416 1417 /* Fill in L2TP header */ 1418 mtod(m, u_int16_t *)[0] = htons(L2TP_CTRL_HDR); --- 61 unchanged lines hidden --- |