Projet

Général

Profil

« Précédent | Suivant » 

Révision a4e82bdf

Ajouté par Ermal il y a presque 10 ans

Make stf match function work as it should

Voir les différences:

patches/stable/10/stf_6rd.diff
173 173
+#undef N
174 174
+}
175 175
diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c
176
index 20251dc..3e24111 100644
176
index 20251dc..532750b 100644
177 177
--- a/sys/net/if_stf.c
178 178
+++ b/sys/net/if_stf.c
179 179
@@ -3,6 +3,8 @@
......
340 340
 static int stfmodevent(module_t, int, void *);
341 341
 static int stf_encapcheck(const struct mbuf *, int, int, void *);
342 342
 static struct in6_ifaddr *stf_getsrcifa6(struct ifnet *);
343
@@ -191,20 +239,25 @@ static int stf_checkaddr6(struct stf_softc *, struct in6_addr *,
343
@@ -191,66 +239,66 @@ static int stf_checkaddr6(struct stf_softc *, struct in6_addr *,
344 344
 static void stf_rtrequest(int, struct rtentry *, struct rt_addrinfo *);
345 345
 static int stf_ioctl(struct ifnet *, u_long, caddr_t);
346 346
 
......
362 362
 stf_clone_match(struct if_clone *ifc, const char *name)
363 363
 {
364 364
-	int i;
365
+	const char *cp;
365 366
 
366 367
-	for(i = 0; stfnames[i] != NULL; i++) {
367 368
-		if (strcmp(stfnames[i], name) == 0)
368 369
-			return (1);
369 370
-	}
370
+	if (strcmp(stfname, name) == 0)
371
+		return (1);
371
+	if (strncmp(stfname, name, strlen(stfname) != 0)
372
+		return (0);
372 373
 
373
 	return (0);
374
-	return (0);
375
+	for (cp = name + 3; *cp != '\0'; cp++) {
376
+		if (*cp < '' || *cp > '9')
377
+			return (0);
378
+	}
379
+	return (1);
374 380
 }
375
@@ -212,45 +265,35 @@ stf_clone_match(struct if_clone *ifc, const char *name)
381
 
376 382
 static int
377 383
 stf_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
378 384
 {
......
431 437
 		return (ENOMEM);
432 438
 	}
433 439
 
434
@@ -260,6 +303,11 @@ stf_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
440
@@ -260,6 +308,11 @@ stf_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
435 441
 	ifp->if_snd.ifq_maxlen = ifqmaxlen;
436 442
 	if_attach(ifp);
437 443
 	bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
......
443 449
 	return (0);
444 450
 }
445 451
 
446
@@ -267,35 +315,48 @@ static int
452
@@ -267,35 +320,48 @@ static int
447 453
 stf_clone_destroy(struct if_clone *ifc, struct ifnet *ifp)
448 454
 {
449 455
 	struct stf_softc *sc = ifp->if_softc;
......
498 504
 		break;
499 505
 	default:
500 506
 		return (EOPNOTSUPP);
501
@@ -311,28 +372,31 @@ static moduledata_t stf_mod = {
507
@@ -311,28 +377,31 @@ static moduledata_t stf_mod = {
502 508
 };
503 509
 
504 510
 DECLARE_MODULE(if_stf, stf_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
......
538 544
 		return 0;
539 545
 
540 546
 	if (proto != IPPROTO_IPV6)
541
@@ -344,72 +408,156 @@ stf_encapcheck(m, off, proto, arg)
547
@@ -344,72 +413,156 @@ stf_encapcheck(m, off, proto, arg)
542 548
 	if (ip.ip_v != 4)
543 549
 		return 0;
544 550
 
......
731 737
 }
732 738
 
733 739
 static int
734
@@ -419,8 +567,8 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
740
@@ -419,8 +572,8 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
735 741
 	struct stf_softc *sc;
736 742
 	const struct sockaddr_in6 *dst6;
737 743
 	struct route *cached_route;
......
742 748
 	struct sockaddr_in *dst4;
743 749
 	u_int8_t tos;
744 750
 	struct ip *ip;
745
@@ -472,20 +620,32 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
751
@@ -472,20 +625,32 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
746 752
 	/*
747 753
 	 * Pickup the right outer dst addr from the list of candidates.
748 754
 	 * ip6_dst has priority as it may be able to give us shorter IPv4 hops.
......
785 791
 	if (bpf_peers_present(ifp->if_bpf)) {
786 792
 		/*
787 793
 		 * We need to prepend the address family as
788
@@ -509,11 +669,26 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
794
@@ -509,11 +674,26 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
789 795
 	ip = mtod(m, struct ip *);
790 796
 
791 797
 	bzero(ip, sizeof(*ip));
......
815 821
 	ip->ip_p = IPPROTO_IPV6;
816 822
 	ip->ip_ttl = ip_stf_ttl;
817 823
 	ip->ip_len = htons(m->m_pkthdr.len);
818
@@ -522,7 +697,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
824
@@ -522,7 +702,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
819 825
 	else
820 826
 		ip_ecn_ingress(ECN_NOCARE, &ip->ip_tos, &tos);
821 827
 
......
824 830
 		cached_route = NULL;
825 831
 		goto sendit;
826 832
 	}
827
@@ -530,7 +705,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
833
@@ -530,7 +710,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
828 834
 	/*
829 835
 	 * Do we have a cached route?
830 836
 	 */
......
833 839
 	dst4 = (struct sockaddr_in *)&sc->sc_ro.ro_dst;
834 840
 	if (dst4->sin_family != AF_INET ||
835 841
 	    bcmp(&dst4->sin_addr, &ip->ip_dst, sizeof(ip->ip_dst)) != 0) {
836
@@ -548,8 +723,15 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
842
@@ -548,8 +728,15 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
837 843
 		rtalloc_fib(&sc->sc_ro, sc->sc_fibnum);
838 844
 		if (sc->sc_ro.ro_rt == NULL) {
839 845
 			m_freem(m);
......
850 856
 			return ENETUNREACH;
851 857
 		}
852 858
 	}
853
@@ -558,35 +740,33 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
859
@@ -558,35 +745,33 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
854 860
 sendit:
855 861
 	M_SETFIB(m, sc->sc_fibnum);
856 862
 	ifp->if_opackets++;
......
895 901
 {
896 902
 	struct in_ifaddr *ia4;
897 903
 
898
@@ -602,13 +782,6 @@ stf_checkaddr4(sc, in, inifp)
904
@@ -602,13 +787,6 @@ stf_checkaddr4(sc, in, inifp)
899 905
 	}
900 906
 
901 907
 	/*
......
909 915
 	 * reject packets with broadcast
910 916
 	 */
911 917
 	IN_IFADDR_RLOCK();
912
@@ -631,7 +804,7 @@ stf_checkaddr4(sc, in, inifp)
918
@@ -631,7 +809,7 @@ stf_checkaddr4(sc, in, inifp)
913 919
 
914 920
 		bzero(&sin, sizeof(sin));
915 921
 		sin.sin_family = AF_INET;
......
918 924
 		sin.sin_addr = *in;
919 925
 		rt = rtalloc1_fib((struct sockaddr *)&sin, 0,
920 926
 		    0UL, sc->sc_fibnum);
921
@@ -652,10 +825,7 @@ stf_checkaddr4(sc, in, inifp)
927
@@ -652,10 +830,7 @@ stf_checkaddr4(sc, in, inifp)
922 928
 }
923 929
 
924 930
 static int
......
930 936
 {
931 937
 	/*
932 938
 	 * check 6to4 addresses
933
@@ -679,9 +849,7 @@ stf_checkaddr6(sc, in6, inifp)
939
@@ -679,9 +854,7 @@ stf_checkaddr6(sc, in6, inifp)
934 940
 }
935 941
 
936 942
 void
......
941 947
 {
942 948
 	int proto;
943 949
 	struct stf_softc *sc;
944
@@ -689,6 +857,7 @@ in_stf_input(m, off)
950
@@ -689,6 +862,7 @@ in_stf_input(m, off)
945 951
 	struct ip6_hdr *ip6;
946 952
 	u_int8_t otos, itos;
947 953
 	struct ifnet *ifp;
......
949 955
 
950 956
 	proto = mtod(m, struct ip *)->ip_p;
951 957
 
952
@@ -712,6 +881,17 @@ in_stf_input(m, off)
958
@@ -712,6 +886,17 @@ in_stf_input(m, off)
953 959
 	mac_ifnet_create_mbuf(ifp, m);
954 960
 #endif
955 961
 
......
967 973
 	/*
968 974
 	 * perform sanity check against outer src/dst.
969 975
 	 * for source, perform ingress filter as well.
970
@@ -732,6 +912,17 @@ in_stf_input(m, off)
976
@@ -732,6 +917,17 @@ in_stf_input(m, off)
971 977
 	}
972 978
 	ip6 = mtod(m, struct ip6_hdr *);
973 979
 
......
985 991
 	/*
986 992
 	 * perform sanity check against inner src/dst.
987 993
 	 * for source, perform ingress filter as well.
988
@@ -742,6 +933,41 @@ in_stf_input(m, off)
994
@@ -742,6 +938,41 @@ in_stf_input(m, off)
989 995
 		return;
990 996
 	}
991 997
 
......
1027 1033
 	itos = (ntohl(ip6->ip6_flow) >> 20) & 0xff;
1028 1034
 	if ((ifp->if_flags & IFF_LINK1) != 0)
1029 1035
 		ip_ecn_egress(ECN_ALLOWED, &otos, &itos);
1030
@@ -751,7 +977,7 @@ in_stf_input(m, off)
1036
@@ -751,7 +982,7 @@ in_stf_input(m, off)
1031 1037
 	ip6->ip6_flow |= htonl((u_int32_t)itos << 20);
1032 1038
 
1033 1039
 	m->m_pkthdr.rcvif = ifp;
......
1036 1042
 	if (bpf_peers_present(ifp->if_bpf)) {
1037 1043
 		/*
1038 1044
 		 * We need to prepend the address family as
1039
@@ -764,6 +990,7 @@ in_stf_input(m, off)
1045
@@ -764,6 +995,7 @@ in_stf_input(m, off)
1040 1046
 		bpf_mtap2(ifp->if_bpf, &af, sizeof(af), m);
1041 1047
 	}
1042 1048
 
......
1044 1050
 	/*
1045 1051
 	 * Put the packet to the network layer input queue according to the
1046 1052
 	 * specified address family.
1047
@@ -778,46 +1005,356 @@ in_stf_input(m, off)
1053
@@ -778,46 +1010,356 @@ in_stf_input(m, off)
1048 1054
 
1049 1055
 /* ARGSUSED */
1050 1056
 static void
......
1418 1424
 		ifa->ifa_rtrequest = stf_rtrequest;
1419 1425
 		ifp->if_flags |= IFF_UP;
1420 1426
 		break;
1421
@@ -849,4 +1386,5 @@ stf_ioctl(ifp, cmd, data)
1427
@@ -849,4 +1391,5 @@ stf_ioctl(ifp, cmd, data)
1422 1428
 	}
1423 1429
 
1424 1430
 	return error;

Formats disponibles : Unified diff