commit a4e82bdf94dac08c67afa09a7204b9cb37cec89d
Author: Ermal <eri@pfsense.org>
Date:   Thu May 8 18:06:35 2014 +0200

    Make stf match function work as it should

diff --git a/patches/stable/10/stf_6rd.diff b/patches/stable/10/stf_6rd.diff
index b27b7be6..066bc864 100644
--- a/patches/stable/10/stf_6rd.diff
+++ b/patches/stable/10/stf_6rd.diff
@@ -173,7 +173,7 @@ index 0000000..8c8b3fb
 +#undef N
 +}
 diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c
-index 20251dc..3e24111 100644
+index 20251dc..532750b 100644
 --- a/sys/net/if_stf.c
 +++ b/sys/net/if_stf.c
 @@ -3,6 +3,8 @@
@@ -340,7 +340,7 @@ index 20251dc..3e24111 100644
  static int stfmodevent(module_t, int, void *);
  static int stf_encapcheck(const struct mbuf *, int, int, void *);
  static struct in6_ifaddr *stf_getsrcifa6(struct ifnet *);
-@@ -191,20 +239,25 @@ static int stf_checkaddr6(struct stf_softc *, struct in6_addr *,
+@@ -191,66 +239,66 @@ static int stf_checkaddr6(struct stf_softc *, struct in6_addr *,
  static void stf_rtrequest(int, struct rtentry *, struct rt_addrinfo *);
  static int stf_ioctl(struct ifnet *, u_long, caddr_t);
  
@@ -362,17 +362,23 @@ index 20251dc..3e24111 100644
  stf_clone_match(struct if_clone *ifc, const char *name)
  {
 -	int i;
++	const char *cp;
  
 -	for(i = 0; stfnames[i] != NULL; i++) {
 -		if (strcmp(stfnames[i], name) == 0)
 -			return (1);
 -	}
-+	if (strcmp(stfname, name) == 0)
-+		return (1);
++	if (strncmp(stfname, name, strlen(stfname) != 0)
++		return (0);
  
- 	return (0);
+-	return (0);
++	for (cp = name + 3; *cp != '\0'; cp++) {
++		if (*cp < '' || *cp > '9')
++			return (0);
++	}
++	return (1);
  }
-@@ -212,45 +265,35 @@ stf_clone_match(struct if_clone *ifc, const char *name)
+ 
  static int
  stf_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
  {
@@ -431,7 +437,7 @@ index 20251dc..3e24111 100644
  		return (ENOMEM);
  	}
  
-@@ -260,6 +303,11 @@ stf_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
+@@ -260,6 +308,11 @@ stf_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
  	ifp->if_snd.ifq_maxlen = ifqmaxlen;
  	if_attach(ifp);
  	bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
@@ -443,7 +449,7 @@ index 20251dc..3e24111 100644
  	return (0);
  }
  
-@@ -267,35 +315,48 @@ static int
+@@ -267,35 +320,48 @@ static int
  stf_clone_destroy(struct if_clone *ifc, struct ifnet *ifp)
  {
  	struct stf_softc *sc = ifp->if_softc;
@@ -498,7 +504,7 @@ index 20251dc..3e24111 100644
  		break;
  	default:
  		return (EOPNOTSUPP);
-@@ -311,28 +372,31 @@ static moduledata_t stf_mod = {
+@@ -311,28 +377,31 @@ static moduledata_t stf_mod = {
  };
  
  DECLARE_MODULE(if_stf, stf_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
@@ -538,7 +544,7 @@ index 20251dc..3e24111 100644
  		return 0;
  
  	if (proto != IPPROTO_IPV6)
-@@ -344,72 +408,156 @@ stf_encapcheck(m, off, proto, arg)
+@@ -344,72 +413,156 @@ stf_encapcheck(m, off, proto, arg)
  	if (ip.ip_v != 4)
  		return 0;
  
@@ -731,7 +737,7 @@ index 20251dc..3e24111 100644
  }
  
  static int
-@@ -419,8 +567,8 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
+@@ -419,8 +572,8 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
  	struct stf_softc *sc;
  	const struct sockaddr_in6 *dst6;
  	struct route *cached_route;
@@ -742,7 +748,7 @@ index 20251dc..3e24111 100644
  	struct sockaddr_in *dst4;
  	u_int8_t tos;
  	struct ip *ip;
-@@ -472,20 +620,32 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
+@@ -472,20 +625,32 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
  	/*
  	 * Pickup the right outer dst addr from the list of candidates.
  	 * ip6_dst has priority as it may be able to give us shorter IPv4 hops.
@@ -785,7 +791,7 @@ index 20251dc..3e24111 100644
  	if (bpf_peers_present(ifp->if_bpf)) {
  		/*
  		 * We need to prepend the address family as
-@@ -509,11 +669,26 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
+@@ -509,11 +674,26 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
  	ip = mtod(m, struct ip *);
  
  	bzero(ip, sizeof(*ip));
@@ -815,7 +821,7 @@ index 20251dc..3e24111 100644
  	ip->ip_p = IPPROTO_IPV6;
  	ip->ip_ttl = ip_stf_ttl;
  	ip->ip_len = htons(m->m_pkthdr.len);
-@@ -522,7 +697,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
+@@ -522,7 +702,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
  	else
  		ip_ecn_ingress(ECN_NOCARE, &ip->ip_tos, &tos);
  
@@ -824,7 +830,7 @@ index 20251dc..3e24111 100644
  		cached_route = NULL;
  		goto sendit;
  	}
-@@ -530,7 +705,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
+@@ -530,7 +710,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
  	/*
  	 * Do we have a cached route?
  	 */
@@ -833,7 +839,7 @@ index 20251dc..3e24111 100644
  	dst4 = (struct sockaddr_in *)&sc->sc_ro.ro_dst;
  	if (dst4->sin_family != AF_INET ||
  	    bcmp(&dst4->sin_addr, &ip->ip_dst, sizeof(ip->ip_dst)) != 0) {
-@@ -548,8 +723,15 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
+@@ -548,8 +728,15 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
  		rtalloc_fib(&sc->sc_ro, sc->sc_fibnum);
  		if (sc->sc_ro.ro_rt == NULL) {
  			m_freem(m);
@@ -850,7 +856,7 @@ index 20251dc..3e24111 100644
  			return ENETUNREACH;
  		}
  	}
-@@ -558,35 +740,33 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
+@@ -558,35 +745,33 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
  sendit:
  	M_SETFIB(m, sc->sc_fibnum);
  	ifp->if_opackets++;
@@ -895,7 +901,7 @@ index 20251dc..3e24111 100644
  {
  	struct in_ifaddr *ia4;
  
-@@ -602,13 +782,6 @@ stf_checkaddr4(sc, in, inifp)
+@@ -602,13 +787,6 @@ stf_checkaddr4(sc, in, inifp)
  	}
  
  	/*
@@ -909,7 +915,7 @@ index 20251dc..3e24111 100644
  	 * reject packets with broadcast
  	 */
  	IN_IFADDR_RLOCK();
-@@ -631,7 +804,7 @@ stf_checkaddr4(sc, in, inifp)
+@@ -631,7 +809,7 @@ stf_checkaddr4(sc, in, inifp)
  
  		bzero(&sin, sizeof(sin));
  		sin.sin_family = AF_INET;
@@ -918,7 +924,7 @@ index 20251dc..3e24111 100644
  		sin.sin_addr = *in;
  		rt = rtalloc1_fib((struct sockaddr *)&sin, 0,
  		    0UL, sc->sc_fibnum);
-@@ -652,10 +825,7 @@ stf_checkaddr4(sc, in, inifp)
+@@ -652,10 +830,7 @@ stf_checkaddr4(sc, in, inifp)
  }
  
  static int
@@ -930,7 +936,7 @@ index 20251dc..3e24111 100644
  {
  	/*
  	 * check 6to4 addresses
-@@ -679,9 +849,7 @@ stf_checkaddr6(sc, in6, inifp)
+@@ -679,9 +854,7 @@ stf_checkaddr6(sc, in6, inifp)
  }
  
  void
@@ -941,7 +947,7 @@ index 20251dc..3e24111 100644
  {
  	int proto;
  	struct stf_softc *sc;
-@@ -689,6 +857,7 @@ in_stf_input(m, off)
+@@ -689,6 +862,7 @@ in_stf_input(m, off)
  	struct ip6_hdr *ip6;
  	u_int8_t otos, itos;
  	struct ifnet *ifp;
@@ -949,7 +955,7 @@ index 20251dc..3e24111 100644
  
  	proto = mtod(m, struct ip *)->ip_p;
  
-@@ -712,6 +881,17 @@ in_stf_input(m, off)
+@@ -712,6 +886,17 @@ in_stf_input(m, off)
  	mac_ifnet_create_mbuf(ifp, m);
  #endif
  
@@ -967,7 +973,7 @@ index 20251dc..3e24111 100644
  	/*
  	 * perform sanity check against outer src/dst.
  	 * for source, perform ingress filter as well.
-@@ -732,6 +912,17 @@ in_stf_input(m, off)
+@@ -732,6 +917,17 @@ in_stf_input(m, off)
  	}
  	ip6 = mtod(m, struct ip6_hdr *);
  
@@ -985,7 +991,7 @@ index 20251dc..3e24111 100644
  	/*
  	 * perform sanity check against inner src/dst.
  	 * for source, perform ingress filter as well.
-@@ -742,6 +933,41 @@ in_stf_input(m, off)
+@@ -742,6 +938,41 @@ in_stf_input(m, off)
  		return;
  	}
  
@@ -1027,7 +1033,7 @@ index 20251dc..3e24111 100644
  	itos = (ntohl(ip6->ip6_flow) >> 20) & 0xff;
  	if ((ifp->if_flags & IFF_LINK1) != 0)
  		ip_ecn_egress(ECN_ALLOWED, &otos, &itos);
-@@ -751,7 +977,7 @@ in_stf_input(m, off)
+@@ -751,7 +982,7 @@ in_stf_input(m, off)
  	ip6->ip6_flow |= htonl((u_int32_t)itos << 20);
  
  	m->m_pkthdr.rcvif = ifp;
@@ -1036,7 +1042,7 @@ index 20251dc..3e24111 100644
  	if (bpf_peers_present(ifp->if_bpf)) {
  		/*
  		 * We need to prepend the address family as
-@@ -764,6 +990,7 @@ in_stf_input(m, off)
+@@ -764,6 +995,7 @@ in_stf_input(m, off)
  		bpf_mtap2(ifp->if_bpf, &af, sizeof(af), m);
  	}
  
@@ -1044,7 +1050,7 @@ index 20251dc..3e24111 100644
  	/*
  	 * Put the packet to the network layer input queue according to the
  	 * specified address family.
-@@ -778,46 +1005,356 @@ in_stf_input(m, off)
+@@ -778,46 +1010,356 @@ in_stf_input(m, off)
  
  /* ARGSUSED */
  static void
@@ -1418,7 +1424,7 @@ index 20251dc..3e24111 100644
  		ifa->ifa_rtrequest = stf_rtrequest;
  		ifp->if_flags |= IFF_UP;
  		break;
-@@ -849,4 +1386,5 @@ stf_ioctl(ifp, cmd, data)
+@@ -849,4 +1391,5 @@ stf_ioctl(ifp, cmd, data)
  	}
  
  	return error;
