Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/ip_gre.c
Show First 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | in_gre_encapcheck(const struct mbuf *m, int off, int proto, void *arg) | ||||
GRE_RUNLOCK(sc); | GRE_RUNLOCK(sc); | ||||
return (32 * 2); | return (32 * 2); | ||||
bad: | bad: | ||||
GRE_RUNLOCK(sc); | GRE_RUNLOCK(sc); | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
in_gre_output(struct mbuf *m, int af, int hlen) | in_gre_output(struct gre_softc *sc, struct mbuf *m, int af, int hlen) | ||||
{ | { | ||||
struct greip *gi; | struct greip *gi; | ||||
gi = mtod(m, struct greip *); | gi = mtod(m, struct greip *); | ||||
switch (af) { | switch (af) { | ||||
case AF_INET: | case AF_INET: | ||||
/* | /* | ||||
* gre_transmit() has used M_PREPEND() that doesn't guarantee | * gre_transmit() has used M_PREPEND() that doesn't guarantee | ||||
* m_data is contiguous more than hlen bytes. Use m_copydata() | * m_data is contiguous more than hlen bytes. Use m_copydata() | ||||
* here to avoid m_pullup(). | * here to avoid m_pullup(). | ||||
*/ | */ | ||||
m_copydata(m, hlen + offsetof(struct ip, ip_tos), | m_copydata(m, hlen + offsetof(struct ip, ip_tos), | ||||
sizeof(u_char), &gi->gi_ip.ip_tos); | sizeof(u_char), &gi->gi_ip.ip_tos); | ||||
m_copydata(m, hlen + offsetof(struct ip, ip_id), | m_copydata(m, hlen + offsetof(struct ip, ip_id), | ||||
sizeof(u_short), (caddr_t)&gi->gi_ip.ip_id); | sizeof(u_short), (caddr_t)&gi->gi_ip.ip_id); | ||||
break; | break; | ||||
#ifdef INET6 | #ifdef INET6 | ||||
case AF_INET6: | case AF_INET6: | ||||
gi->gi_ip.ip_tos = 0; /* XXX */ | gi->gi_ip.ip_tos = 0; /* XXX */ | ||||
ip_fillid(&gi->gi_ip); | ip_fillid(&gi->gi_ip, &sc->gre_ip_id); | ||||
break; | break; | ||||
#endif | #endif | ||||
} | } | ||||
gi->gi_ip.ip_ttl = V_ip_gre_ttl; | gi->gi_ip.ip_ttl = V_ip_gre_ttl; | ||||
gi->gi_ip.ip_len = htons(m->m_pkthdr.len); | gi->gi_ip.ip_len = htons(m->m_pkthdr.len); | ||||
return (ip_output(m, NULL, NULL, IP_FORWARDING, NULL, NULL)); | return (ip_output(m, NULL, NULL, IP_FORWARDING, NULL, NULL)); | ||||
} | } | ||||
Show All 11 Lines |