Deleted Added
full compact
if_stf.c (267992) if_stf.c (269699)
1/* $FreeBSD: head/sys/net/if_stf.c 267992 2014-06-28 03:56:17Z hselasky $ */
1/* $FreeBSD: head/sys/net/if_stf.c 269699 2014-08-08 01:57:15Z kevlo $ */
2/* $KAME: if_stf.c,v 1.73 2001/12/03 11:08:30 keiichi Exp $ */
3
4/*-
5 * Copyright (C) 2000 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions

--- 663 unchanged lines hidden (view full) ---

673 * (2) to be safe against future ip6_input change.
674 */
675 if (IN6_IS_ADDR_V4COMPAT(in6) || IN6_IS_ADDR_V4MAPPED(in6))
676 return -1;
677
678 return 0;
679}
680
2/* $KAME: if_stf.c,v 1.73 2001/12/03 11:08:30 keiichi Exp $ */
3
4/*-
5 * Copyright (C) 2000 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions

--- 663 unchanged lines hidden (view full) ---

673 * (2) to be safe against future ip6_input change.
674 */
675 if (IN6_IS_ADDR_V4COMPAT(in6) || IN6_IS_ADDR_V4MAPPED(in6))
676 return -1;
677
678 return 0;
679}
680
681void
682in_stf_input(m, off)
683 struct mbuf *m;
684 int off;
681int
682in_stf_input(struct mbuf **mp, int *offp, int proto)
685{
683{
686 int proto;
687 struct stf_softc *sc;
688 struct ip *ip;
689 struct ip6_hdr *ip6;
684 struct stf_softc *sc;
685 struct ip *ip;
686 struct ip6_hdr *ip6;
687 struct mbuf *m;
690 u_int8_t otos, itos;
691 struct ifnet *ifp;
688 u_int8_t otos, itos;
689 struct ifnet *ifp;
690 int off;
692
691
693 proto = mtod(m, struct ip *)->ip_p;
692 m = *mp;
693 off = *offp;
694
695 if (proto != IPPROTO_IPV6) {
696 m_freem(m);
694
695 if (proto != IPPROTO_IPV6) {
696 m_freem(m);
697 return;
697 return (IPPROTO_DONE);
698 }
699
700 ip = mtod(m, struct ip *);
701
702 sc = (struct stf_softc *)encap_getarg(m);
703
704 if (sc == NULL || (STF2IFP(sc)->if_flags & IFF_UP) == 0) {
705 m_freem(m);
698 }
699
700 ip = mtod(m, struct ip *);
701
702 sc = (struct stf_softc *)encap_getarg(m);
703
704 if (sc == NULL || (STF2IFP(sc)->if_flags & IFF_UP) == 0) {
705 m_freem(m);
706 return;
706 return (IPPROTO_DONE);
707 }
708
709 ifp = STF2IFP(sc);
710
711#ifdef MAC
712 mac_ifnet_create_mbuf(ifp, m);
713#endif
714
715 /*
716 * perform sanity check against outer src/dst.
717 * for source, perform ingress filter as well.
718 */
719 if (stf_checkaddr4(sc, &ip->ip_dst, NULL) < 0 ||
720 stf_checkaddr4(sc, &ip->ip_src, m->m_pkthdr.rcvif) < 0) {
721 m_freem(m);
707 }
708
709 ifp = STF2IFP(sc);
710
711#ifdef MAC
712 mac_ifnet_create_mbuf(ifp, m);
713#endif
714
715 /*
716 * perform sanity check against outer src/dst.
717 * for source, perform ingress filter as well.
718 */
719 if (stf_checkaddr4(sc, &ip->ip_dst, NULL) < 0 ||
720 stf_checkaddr4(sc, &ip->ip_src, m->m_pkthdr.rcvif) < 0) {
721 m_freem(m);
722 return;
722 return (IPPROTO_DONE);
723 }
724
725 otos = ip->ip_tos;
726 m_adj(m, off);
727
728 if (m->m_len < sizeof(*ip6)) {
729 m = m_pullup(m, sizeof(*ip6));
730 if (!m)
723 }
724
725 otos = ip->ip_tos;
726 m_adj(m, off);
727
728 if (m->m_len < sizeof(*ip6)) {
729 m = m_pullup(m, sizeof(*ip6));
730 if (!m)
731 return;
731 return (IPPROTO_DONE);
732 }
733 ip6 = mtod(m, struct ip6_hdr *);
734
735 /*
736 * perform sanity check against inner src/dst.
737 * for source, perform ingress filter as well.
738 */
739 if (stf_checkaddr6(sc, &ip6->ip6_dst, NULL) < 0 ||
740 stf_checkaddr6(sc, &ip6->ip6_src, m->m_pkthdr.rcvif) < 0) {
741 m_freem(m);
732 }
733 ip6 = mtod(m, struct ip6_hdr *);
734
735 /*
736 * perform sanity check against inner src/dst.
737 * for source, perform ingress filter as well.
738 */
739 if (stf_checkaddr6(sc, &ip6->ip6_dst, NULL) < 0 ||
740 stf_checkaddr6(sc, &ip6->ip6_src, m->m_pkthdr.rcvif) < 0) {
741 m_freem(m);
742 return;
742 return (IPPROTO_DONE);
743 }
744
745 itos = (ntohl(ip6->ip6_flow) >> 20) & 0xff;
746 if ((ifp->if_flags & IFF_LINK1) != 0)
747 ip_ecn_egress(ECN_ALLOWED, &otos, &itos);
748 else
749 ip_ecn_egress(ECN_NOCARE, &otos, &itos);
750 ip6->ip6_flow &= ~htonl(0xff << 20);

--- 18 unchanged lines hidden (view full) ---

769 * specified address family.
770 * See net/if_gif.c for possible issues with packet processing
771 * reorder due to extra queueing.
772 */
773 ifp->if_ipackets++;
774 ifp->if_ibytes += m->m_pkthdr.len;
775 M_SETFIB(m, ifp->if_fib);
776 netisr_dispatch(NETISR_IPV6, m);
743 }
744
745 itos = (ntohl(ip6->ip6_flow) >> 20) & 0xff;
746 if ((ifp->if_flags & IFF_LINK1) != 0)
747 ip_ecn_egress(ECN_ALLOWED, &otos, &itos);
748 else
749 ip_ecn_egress(ECN_NOCARE, &otos, &itos);
750 ip6->ip6_flow &= ~htonl(0xff << 20);

--- 18 unchanged lines hidden (view full) ---

769 * specified address family.
770 * See net/if_gif.c for possible issues with packet processing
771 * reorder due to extra queueing.
772 */
773 ifp->if_ipackets++;
774 ifp->if_ibytes += m->m_pkthdr.len;
775 M_SETFIB(m, ifp->if_fib);
776 netisr_dispatch(NETISR_IPV6, m);
777 return (IPPROTO_DONE);
777}
778
779/* ARGSUSED */
780static void
781stf_rtrequest(cmd, rt, info)
782 int cmd;
783 struct rtentry *rt;
784 struct rt_addrinfo *info;

--- 68 unchanged lines hidden ---
778}
779
780/* ARGSUSED */
781static void
782stf_rtrequest(cmd, rt, info)
783 int cmd;
784 struct rtentry *rt;
785 struct rt_addrinfo *info;

--- 68 unchanged lines hidden ---