in_gif.c (185571) | in_gif.c (189494) |
---|---|
1/* $KAME: in_gif.c,v 1.54 2001/05/14 14:02:16 itojun Exp $ */ 2 3/*- 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 16 unchanged lines hidden (view full) --- 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 */ 31 32#include <sys/cdefs.h> | 1/* $KAME: in_gif.c,v 1.54 2001/05/14 14:02:16 itojun Exp $ */ 2 3/*- 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 16 unchanged lines hidden (view full) --- 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/netinet/in_gif.c 185571 2008-12-02 21:37:28Z bz $"); | 33__FBSDID("$FreeBSD: head/sys/netinet/in_gif.c 189494 2009-03-07 19:08:58Z marius $"); |
34 35#include "opt_mrouting.h" 36#include "opt_inet.h" 37#include "opt_inet6.h" 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/socket.h> --- 55 unchanged lines hidden (view full) --- 97{ 98 INIT_VNET_GIF(ifp->if_vnet); 99 struct gif_softc *sc = ifp->if_softc; 100 struct sockaddr_in *dst = (struct sockaddr_in *)&sc->gif_ro.ro_dst; 101 struct sockaddr_in *sin_src = (struct sockaddr_in *)sc->gif_psrc; 102 struct sockaddr_in *sin_dst = (struct sockaddr_in *)sc->gif_pdst; 103 struct ip iphdr; /* capsule IP header, host byte ordered */ 104 struct etherip_header eiphdr; | 34 35#include "opt_mrouting.h" 36#include "opt_inet.h" 37#include "opt_inet6.h" 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/socket.h> --- 55 unchanged lines hidden (view full) --- 97{ 98 INIT_VNET_GIF(ifp->if_vnet); 99 struct gif_softc *sc = ifp->if_softc; 100 struct sockaddr_in *dst = (struct sockaddr_in *)&sc->gif_ro.ro_dst; 101 struct sockaddr_in *sin_src = (struct sockaddr_in *)sc->gif_psrc; 102 struct sockaddr_in *sin_dst = (struct sockaddr_in *)sc->gif_pdst; 103 struct ip iphdr; /* capsule IP header, host byte ordered */ 104 struct etherip_header eiphdr; |
105 int proto, error; | 105 int error, len, proto; |
106 u_int8_t tos; 107 108 GIF_LOCK_ASSERT(sc); 109 110 if (sin_src == NULL || sin_dst == NULL || 111 sin_src->sin_family != AF_INET || 112 sin_dst->sin_family != AF_INET) { 113 m_freem(m); --- 67 unchanged lines hidden (view full) --- 181 iphdr.ip_p = proto; 182 /* version will be set in ip_output() */ 183 iphdr.ip_ttl = V_ip_gif_ttl; 184 iphdr.ip_len = m->m_pkthdr.len + sizeof(struct ip); 185 ip_ecn_ingress((ifp->if_flags & IFF_LINK1) ? ECN_ALLOWED : ECN_NOCARE, 186 &iphdr.ip_tos, &tos); 187 188 /* prepend new IP header */ | 106 u_int8_t tos; 107 108 GIF_LOCK_ASSERT(sc); 109 110 if (sin_src == NULL || sin_dst == NULL || 111 sin_src->sin_family != AF_INET || 112 sin_dst->sin_family != AF_INET) { 113 m_freem(m); --- 67 unchanged lines hidden (view full) --- 181 iphdr.ip_p = proto; 182 /* version will be set in ip_output() */ 183 iphdr.ip_ttl = V_ip_gif_ttl; 184 iphdr.ip_len = m->m_pkthdr.len + sizeof(struct ip); 185 ip_ecn_ingress((ifp->if_flags & IFF_LINK1) ? ECN_ALLOWED : ECN_NOCARE, 186 &iphdr.ip_tos, &tos); 187 188 /* prepend new IP header */ |
189 M_PREPEND(m, sizeof(struct ip), M_DONTWAIT); 190 if (m && m->m_len < sizeof(struct ip)) 191 m = m_pullup(m, sizeof(struct ip)); | 189 len = sizeof(struct ip); 190#ifndef __NO_STRICT_ALIGNMENT 191 if (family == AF_LINK) 192 len += ETHERIP_ALIGN; 193#endif 194 M_PREPEND(m, len, M_DONTWAIT); 195 if (m != NULL && m->m_len < len) 196 m = m_pullup(m, len); |
192 if (m == NULL) { 193 printf("ENOBUFS in in_gif_output %d\n", __LINE__); 194 return ENOBUFS; 195 } | 197 if (m == NULL) { 198 printf("ENOBUFS in in_gif_output %d\n", __LINE__); 199 return ENOBUFS; 200 } |
201#ifndef __NO_STRICT_ALIGNMENT 202 if (family == AF_LINK) { 203 len = mtod(m, vm_offset_t) & 3; 204 KASSERT(len == 0 || len == ETHERIP_ALIGN, 205 ("in_gif_output: unexpected misalignment")); 206 m->m_data += len; 207 m->m_len -= ETHERIP_ALIGN; 208 } 209#endif |
|
196 bcopy(&iphdr, mtod(m, struct ip *), sizeof(struct ip)); 197 198 M_SETFIB(m, sc->gif_fibnum); 199 200 if (dst->sin_family != sin_dst->sin_family || 201 dst->sin_addr.s_addr != sin_dst->sin_addr.s_addr) { 202 /* cache route doesn't match */ 203 bzero(dst, sizeof(*dst)); --- 235 unchanged lines hidden --- | 210 bcopy(&iphdr, mtod(m, struct ip *), sizeof(struct ip)); 211 212 M_SETFIB(m, sc->gif_fibnum); 213 214 if (dst->sin_family != sin_dst->sin_family || 215 dst->sin_addr.s_addr != sin_dst->sin_addr.s_addr) { 216 /* cache route doesn't match */ 217 bzero(dst, sizeof(*dst)); --- 235 unchanged lines hidden --- |