ng_l2tp.c (102244) | ng_l2tp.c (108107) |
---|---|
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 102244 2002-08-22 00:30:03Z archie $ | 40 * $FreeBSD: head/sys/netgraph/ng_l2tp.c 108107 2002-12-19 22:58:27Z bmilekic $ |
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 */ 49 50#include <sys/param.h> 51#include <sys/systm.h> 52#include <sys/kernel.h> 53#include <sys/time.h> 54#include <sys/conf.h> 55#include <sys/mbuf.h> 56#include <sys/malloc.h> 57#include <sys/errno.h> | 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 */ 49 50#include <sys/param.h> 51#include <sys/systm.h> 52#include <sys/kernel.h> 53#include <sys/time.h> 54#include <sys/conf.h> 55#include <sys/mbuf.h> 56#include <sys/malloc.h> 57#include <sys/errno.h> |
58#include <sys/libkern.h> |
|
58 59#include <netgraph/ng_message.h> 60#include <netgraph/netgraph.h> 61#include <netgraph/ng_parse.h> 62#include <netgraph/ng_l2tp.h> 63 64#ifdef NG_SEPARATE_MALLOC 65MALLOC_DEFINE(M_NETGRAPH_L2TP, "netgraph_l2tp", "netgraph l2tp node"); --- 224 unchanged lines hidden (view full) --- 290 291/* Sequence number state sanity checking */ 292#ifdef INVARIANTS 293#define L2TP_SEQ_CHECK(seq) ng_l2tp_seq_check(seq) 294#else 295#define L2TP_SEQ_CHECK(x) do { } while (0) 296#endif 297 | 59 60#include <netgraph/ng_message.h> 61#include <netgraph/netgraph.h> 62#include <netgraph/ng_parse.h> 63#include <netgraph/ng_l2tp.h> 64 65#ifdef NG_SEPARATE_MALLOC 66MALLOC_DEFINE(M_NETGRAPH_L2TP, "netgraph_l2tp", "netgraph l2tp node"); --- 224 unchanged lines hidden (view full) --- 291 292/* Sequence number state sanity checking */ 293#ifdef INVARIANTS 294#define L2TP_SEQ_CHECK(seq) ng_l2tp_seq_check(seq) 295#else 296#define L2TP_SEQ_CHECK(x) do { } while (0) 297#endif 298 |
298/* mem*() macros */ | 299/* memmove macro */ |
299#define memmove(d, s, l) ovbcopy(s, d, l) | 300#define memmove(d, s, l) ovbcopy(s, d, l) |
300#define memset(d, z, l) bzero(d, l) /* XXX */ | |
301 302/* Whether to use m_copypacket() or m_dup() */ 303#define L2TP_COPY_MBUF m_copypacket 304 305/************************************************************************ 306 NETGRAPH NODE STUFF 307************************************************************************/ 308 --- 641 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 */ | 301 302/* Whether to use m_copypacket() or m_dup() */ 303#define L2TP_COPY_MBUF m_copypacket 304 305/************************************************************************ 306 NETGRAPH NODE STUFF 307************************************************************************/ 308 --- 641 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_NOWAIT)) == NULL) { | 958 if ((m = L2TP_COPY_MBUF(seq->xwin[i], M_DONTWAIT)) == 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 --- 247 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) { | 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 --- 247 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_NOWAIT)) == NULL) | 1222 if ((m = L2TP_COPY_MBUF(seq->xwin[i], M_DONTWAIT)) == 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_NOWAIT)) == NULL) | 1364 if ((m = L2TP_COPY_MBUF(seq->xwin[0], M_DONTWAIT)) == 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); --- 107 unchanged lines hidden --- | 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); --- 107 unchanged lines hidden --- |