Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Nov 1995 21:29:59 +0200 (SAT)
From:      John Hay <jhay@mikom.csir.co.za>
To:        freebsd-current@FreeBSD.ORG (FreeBSD-current)
Cc:        peter@FreeBSD.ORG, vak@zebub.msk.su
Subject:   patches to if_spppsubr.c
Message-ID:  <199511201929.VAA09329@zibbi.mikom.csir.co.za>

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

Here is a few patches to sys/net/if_spppsubr.c. It does the following:

If a lcp configure request is received in the lcp opened state and it
is acknowledged, it should go to the lcp ack sent state.

Don't reply on lcp echo requests when not in the lcp opened state.

If the interface is set to CISCO mode, it should still be marked
running when ifconfiged.

Fixed a few indentations that had gone wrong somewhere.

John
-- 
John Hay -- John.Hay@csir.co.za


*** if_spppsubr.c.org	Fri Oct 27 07:46:18 1995
--- if_spppsubr.c	Mon Nov 20 21:19:18 1995
***************
*** 357,372 ****
  	 * Put low delay, telnet, rlogin and ftp control packets
  	 * in front of the queue.
  	 */
! 	{
! 	struct ip *ip = mtod (m, struct ip*);
! 	struct tcphdr *tcp = (struct tcphdr*) ((long*)ip + ip->ip_hl);
! 
! 	if (! IF_QFULL (&sp->pp_fastq) && ((ip->ip_tos & IPTOS_LOWDELAY) ||
! 	    ip->ip_p == IPPROTO_TCP &&
! 	    m->m_len >= sizeof (struct ip) + sizeof (struct tcphdr) &&
! 	    (INTERACTIVE (ntohs (tcp->th_sport)) ||
! 	    INTERACTIVE (ntohs (tcp->th_dport)))))
! 		ifq = &sp->pp_fastq;
  	}
  #endif
  
--- 357,373 ----
  	 * Put low delay, telnet, rlogin and ftp control packets
  	 * in front of the queue.
  	 */
! 	if (dst->sa_family == AF_INET) {
! 		struct ip *ip = mtod (m, struct ip*);
! 		struct tcphdr *tcp = (struct tcphdr*) ((long*)ip + ip->ip_hl);
! 
! 		if (! IF_QFULL (&sp->pp_fastq) &&
! 		    ((ip->ip_tos & IPTOS_LOWDELAY) ||
! 	    	    ip->ip_p == IPPROTO_TCP &&
! 	    	    m->m_len >= sizeof (struct ip) + sizeof (struct tcphdr) &&
! 	    	    (INTERACTIVE (ntohs (tcp->th_sport)) ||
! 	    	    INTERACTIVE (ntohs (tcp->th_dport)))))
! 			ifq = &sp->pp_fastq;
  	}
  #endif
  
***************
*** 674,692 ****
  				sp->ipcp.state = IPCP_STATE_CLOSED;
  			}
  			break;
! 				}
! 				/* Send Configure-Ack packet. */
! 				sp->pp_loopcnt = 0;
! 				sppp_cp_send (sp, PPP_LCP, LCP_CONF_ACK,
! 					h->ident, len-4, h+1);
! 				/* Change the state. */
  		switch (sp->lcp.state) {
  		case LCP_STATE_CLOSED:
  			sp->lcp.state = LCP_STATE_ACK_SENT;
  			break;
  		case LCP_STATE_ACK_RCVD:
! 					sp->lcp.state = LCP_STATE_OPENED;
! 					sppp_ipcp_open (sp);
  			break;
  		case LCP_STATE_OPENED:
  			/* Remote magic changed -- close session. */
--- 675,693 ----
  				sp->ipcp.state = IPCP_STATE_CLOSED;
  			}
  			break;
! 		}
! 		/* Send Configure-Ack packet. */
! 		sp->pp_loopcnt = 0;
! 		sppp_cp_send (sp, PPP_LCP, LCP_CONF_ACK,
! 				h->ident, len-4, h+1);
! 		/* Change the state. */
  		switch (sp->lcp.state) {
  		case LCP_STATE_CLOSED:
  			sp->lcp.state = LCP_STATE_ACK_SENT;
  			break;
  		case LCP_STATE_ACK_RCVD:
! 			sp->lcp.state = LCP_STATE_OPENED;
! 			sppp_ipcp_open (sp);
  			break;
  		case LCP_STATE_OPENED:
  			/* Remote magic changed -- close session. */
***************
*** 694,699 ****
--- 695,702 ----
  			sp->ipcp.state = IPCP_STATE_CLOSED;
  			/* Initiate renegotiation. */
  			sppp_lcp_open (sp);
+ 			/* An ACK has already been sent. */
+ 			sp->lcp.state = LCP_STATE_ACK_SENT;
  			break;
  		}
  		break;
***************
*** 762,769 ****
  		/* Go to closed state. */
  		sp->lcp.state = LCP_STATE_CLOSED;
  		sp->ipcp.state = IPCP_STATE_CLOSED;
! 			/* Initiate renegotiation. */
! 			sppp_lcp_open (sp);
  		break;
  	case LCP_TERM_ACK:
  	case LCP_CODE_REJ:
--- 765,772 ----
  		/* Go to closed state. */
  		sp->lcp.state = LCP_STATE_CLOSED;
  		sp->ipcp.state = IPCP_STATE_CLOSED;
! 		/* Initiate renegotiation. */
! 		sppp_lcp_open (sp);
  		break;
  	case LCP_TERM_ACK:
  	case LCP_CODE_REJ:
***************
*** 774,779 ****
--- 777,784 ----
  		/* Discard the packet. */
  		break;
  	case LCP_ECHO_REQ:
+ 		if (sp->lcp.state != LCP_STATE_OPENED)
+ 			break;
  		if (len < 8) {
  			if (ifp->if_flags & IFF_DEBUG)
  				printf ("%s%d: invalid lcp echo request packet length: %d bytes\n",
***************
*** 1006,1013 ****
  		/* fall through... */
  
  	case SIOCSIFFLAGS:
- 		if (sp->pp_flags & PP_CISCO)
- 			break;
  		s = splimp ();
  		going_up   = (ifp->if_flags & IFF_UP) &&
  			     ! (ifp->if_flags & IFF_RUNNING);
--- 1011,1016 ----
***************
*** 1023,1029 ****
  		if (going_up) {
  			/* Interface is starting -- initiate negotiation. */
  			ifp->if_flags |= IFF_RUNNING;
! 			sppp_lcp_open (sp);
  		}
  		splx (s);
  		break;
--- 1026,1033 ----
  		if (going_up) {
  			/* Interface is starting -- initiate negotiation. */
  			ifp->if_flags |= IFF_RUNNING;
! 			if (!(sp->pp_flags & PP_CISCO))
! 				sppp_lcp_open (sp);
  		}
  		splx (s);
  		break;
***************
*** 1109,1115 ****
  			bcopy (p, r, p[1]);
  			r += p[1];
  		rlen += p[1];
! 		}
  	if (rlen)
  	sppp_cp_send (sp, PPP_LCP, LCP_CONF_REJ, h->ident, rlen, buf);
  	free (buf, M_TEMP);
--- 1113,1119 ----
  			bcopy (p, r, p[1]);
  			r += p[1];
  		rlen += p[1];
! 	}
  	if (rlen)
  	sppp_cp_send (sp, PPP_LCP, LCP_CONF_REJ, h->ident, rlen, buf);
  	free (buf, M_TEMP);



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