Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Apr 1999 14:48:11 +0200
From:      Poul-Henning Kamp <phk@freebsd.org>
To:        isdn@freebsd.org
Subject:   sppp patches, please test!
Message-ID:  <2946.924266891@critter.freebsd.dk>

next in thread | raw e-mail | index | archive | help

Please test this patch to the sppp code.  I should not affect
I4B users, but I want to give you a chance to protest before
I commit it...

Index: if_spppsubr.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if_spppsubr.c,v
retrieving revision 1.55
diff -u -r1.55 if_spppsubr.c
--- if_spppsubr.c	1999/03/30 13:28:26	1.55
+++ if_spppsubr.c	1999/03/30 15:38:30
@@ -981,9 +981,6 @@
 		}
 
 		if (going_up) {
-			if (sp->pp_mode != IFF_CISCO) 
-				lcp.Close(sp);
-			sp->pp_mode = newmode;
 			if (sp->pp_mode == 0) {
 				ifp->if_flags |= IFF_RUNNING;
 				lcp.Open(sp);
@@ -1837,6 +1834,8 @@
 {
 	STDDCL;
 
+	if (sp->pp_mode == IFF_CISCO)
+		return;
 	/*
 	 * If this interface is passive or dial-on-demand, and we are
 	 * still in Initial state, it means we've got an incoming
@@ -1866,6 +1865,8 @@
 
 	sppp_down_event(&lcp, sp);
 
+	if (sp->pp_mode == IFF_CISCO)
+		return;
 	/*
 	 * If this is neither a dial-on-demand nor a passive
 	 * interface, simulate an ``ifconfig down'' action, so the
@@ -2031,36 +2032,29 @@
 					addlog("0x%lx ", nmagic);
 				continue;
 			}
+
 			/*
 			 * Local and remote magics equal -- loopback?
+			 * We ignore this packet and choose a new magic
+			 * for our side.  In the loopback case we will
+			 * SCR with the new magic when the timer fires,
+			 * it will come back here and get discarded too.
+			 * In case of a magic collision this should work
+			 * as well, since we cannot have received an ACK
+			 * for our magic, the next SCR will have our
+			 * new magic in it, and peers next RCR will 
+			 * have either the same or new magic too.  If it
+			 * is the same one it will be ok by then, since
+			 * we have a new magic (This is not the RFC1661 
+			 * suggested handling) /phk
 			 */
-			if (sp->pp_loopcnt >= MAXALIVECNT*5) {
-				printf (SPP_FMT "loopback\n",
-					SPP_ARGS(ifp));
-				sp->pp_loopcnt = 0;
-				if (ifp->if_flags & IFF_UP) {
-					if_down(ifp);
-					sppp_qflush(&sp->pp_cpq);
-					/* XXX ? */
-					lcp.Down(sp);
-					lcp.Up(sp);
-				}
-			} else if (debug)
-				addlog("[glitch] ");
-			++sp->pp_loopcnt;
-			/*
-			 * We negate our magic here, and NAK it.  If
-			 * we see it later in an NAK packet, we
-			 * suggest a new one.
-			 */
-			nmagic = ~sp->lcp.magic;
-			/* Gonna NAK it. */
-			p[2] = nmagic >> 24;
-			p[3] = nmagic >> 16;
-			p[4] = nmagic >> 8;
-			p[5] = nmagic;
-			break;
 
+			if (debug)
+				addlog("loopback ?\n");
+			sp->lcp.magic = 0;
+			free (buf, M_TEMP);
+			return (0);
+
 		case LCP_OPT_ASYNC_MAP:
 			/* Async control character map -- check to be zero. */
 			if (! p[2] && ! p[3] && ! p[4] && ! p[5]) {
@@ -2207,7 +2201,6 @@
 {
 	STDDCL;
 	u_char *buf, *p;
-	u_long magic;
 
 	len -= 4;
 	buf = malloc (len, M_TEMP, M_NOWAIT);
@@ -2227,26 +2220,7 @@
 			/* Magic number -- renegotiate */
 			if ((sp->lcp.opts & (1 << LCP_OPT_MAGIC)) &&
 			    len >= 6 && p[1] == 6) {
-				magic = (u_long)p[2] << 24 |
-					(u_long)p[3] << 16 | p[4] << 8 | p[5];
-				/*
-				 * If the remote magic is our negated one,
-				 * this looks like a loopback problem.
-				 * Suggest a new magic to make sure.
-				 */
-				if (magic == ~sp->lcp.magic) {
-					if (debug)
-						addlog("magic glitch ");
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
-					sp->lcp.magic = random();
-#else
-					sp->lcp.magic = time.tv_sec + time.tv_usec;
-#endif
-				} else {
-					sp->lcp.magic = magic;
-					if (debug)
-						addlog("%lu ", magic);
-				}
+				sp->lcp.magic = 0;
 			}
 			break;
 		case LCP_OPT_MRU:
@@ -2539,9 +2513,8 @@
 		 * negotiate my address.
 		 */
 		sp->ipcp.flags |= IPCP_MYADDR_DYN;
-		sp->ipcp.opts |= (1 << IPCP_OPT_ADDRESS);
-	} else
-		sp->ipcp.flags |= IPCP_MYADDR_SEEN;
+	}
+	sp->ipcp.opts |= (1 << IPCP_OPT_ADDRESS);
 	sppp_open_event(&ipcp, sp);
 }
 
@@ -2804,7 +2777,7 @@
 				 * we accept his offer.  Otherwise, we
 				 * ignore it and thus continue to negotiate
 				 * our already existing value.
-			 	 * XXX: Bogus, if he said no once, he'll
+			 	 * XXX: Bogus? if he said no once, he'll
 				 * just say no again, might as well die.
 				 */
 				if (sp->ipcp.flags & IPCP_MYADDR_DYN) {
--
Poul-Henning Kamp             FreeBSD coreteam member
phk@FreeBSD.ORG               "Real hackers run -current on their laptop."
FreeBSD -- It will take a long time before progress goes too far!


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-isdn" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2946.924266891>