| version 1.275.2.2, 2009/04/28 07:37:22 |
version 1.276, 2008/11/23 19:52:38 |
|
|
| __KERNEL_RCSID(0, "$NetBSD$"); |
__KERNEL_RCSID(0, "$NetBSD$"); |
| |
|
| #include "opt_inet.h" |
#include "opt_inet.h" |
| #include "opt_compat_netbsd.h" |
|
| #include "opt_gateway.h" |
#include "opt_gateway.h" |
| #include "opt_pfil_hooks.h" |
#include "opt_pfil_hooks.h" |
| #include "opt_ipsec.h" |
#include "opt_ipsec.h" |
| Line 174 __KERNEL_RCSID(0, "$NetBSD$"); |
|
| Line 173 __KERNEL_RCSID(0, "$NetBSD$"); |
|
| #define IPMTUDISCTIMEOUT (10 * 60) /* as per RFC 1191 */ |
#define IPMTUDISCTIMEOUT (10 * 60) /* as per RFC 1191 */ |
| #endif |
#endif |
| |
|
| #ifdef COMPAT_50 |
|
| #include <compat/sys/time.h> |
|
| #include <compat/sys/socket.h> |
|
| #endif |
|
| |
|
| /* |
/* |
| * Note: DIRECTED_BROADCAST is handled this way so that previous |
* Note: DIRECTED_BROADCAST is handled this way so that previous |
| * configuration using this option will Just Work. |
* configuration using this option will Just Work. |
| Line 1128 ip_reass(struct ipqent *ipqe, struct ipq |
|
| Line 1122 ip_reass(struct ipqent *ipqe, struct ipq |
|
| else if (ip_nfragpackets >= ip_maxfragpackets) |
else if (ip_nfragpackets >= ip_maxfragpackets) |
| goto dropfrag; |
goto dropfrag; |
| ip_nfragpackets++; |
ip_nfragpackets++; |
| fp = malloc(sizeof (struct ipq), M_FTABLE, M_NOWAIT); |
MALLOC(fp, struct ipq *, sizeof (struct ipq), |
| |
M_FTABLE, M_NOWAIT); |
| if (fp == NULL) |
if (fp == NULL) |
| goto dropfrag; |
goto dropfrag; |
| LIST_INSERT_HEAD(ipqhead, fp, ipq_q); |
LIST_INSERT_HEAD(ipqhead, fp, ipq_q); |
|
|
| ip->ip_src = fp->ipq_src; |
ip->ip_src = fp->ipq_src; |
| ip->ip_dst = fp->ipq_dst; |
ip->ip_dst = fp->ipq_dst; |
| LIST_REMOVE(fp, ipq_q); |
LIST_REMOVE(fp, ipq_q); |
| free(fp, M_FTABLE); |
FREE(fp, M_FTABLE); |
| ip_nfragpackets--; |
ip_nfragpackets--; |
| m->m_len += (ip->ip_hl << 2); |
m->m_len += (ip->ip_hl << 2); |
| m->m_data -= (ip->ip_hl << 2); |
m->m_data -= (ip->ip_hl << 2); |
| Line 1312 ip_freef(struct ipq *fp) |
|
| Line 1307 ip_freef(struct ipq *fp) |
|
| printf("ip_freef: nfrags %d != %d\n", fp->ipq_nfrags, nfrags); |
printf("ip_freef: nfrags %d != %d\n", fp->ipq_nfrags, nfrags); |
| ip_nfrags -= nfrags; |
ip_nfrags -= nfrags; |
| LIST_REMOVE(fp, ipq_q); |
LIST_REMOVE(fp, ipq_q); |
| free(fp, M_FTABLE); |
FREE(fp, M_FTABLE); |
| ip_nfragpackets--; |
ip_nfragpackets--; |
| } |
} |
| |
|
| Line 1562 ip_dooptions(struct mbuf *m) |
|
| Line 1557 ip_dooptions(struct mbuf *m) |
|
| /* |
/* |
| * locate outgoing interface |
* locate outgoing interface |
| */ |
*/ |
| memcpy((void *)&ipaddr.sin_addr, (void *)(cp + off), |
bcopy((void *)(cp + off), (void *)&ipaddr.sin_addr, |
| sizeof(ipaddr.sin_addr)); |
sizeof(ipaddr.sin_addr)); |
| if (opt == IPOPT_SSRR) |
if (opt == IPOPT_SSRR) |
| ia = ifatoia(ifa_ifwithladdr(sintosa(&ipaddr))); |
ia = ifatoia(ifa_ifwithladdr(sintosa(&ipaddr))); |
| Line 1598 ip_dooptions(struct mbuf *m) |
|
| Line 1593 ip_dooptions(struct mbuf *m) |
|
| off--; /* 0 origin */ |
off--; /* 0 origin */ |
| if ((off + sizeof(struct in_addr)) > optlen) |
if ((off + sizeof(struct in_addr)) > optlen) |
| break; |
break; |
| memcpy((void *)&ipaddr.sin_addr, (void *)(&ip->ip_dst), |
bcopy((void *)(&ip->ip_dst), (void *)&ipaddr.sin_addr, |
| sizeof(ipaddr.sin_addr)); |
sizeof(ipaddr.sin_addr)); |
| /* |
/* |
| * locate outgoing interface; if we're the destination, |
* locate outgoing interface; if we're the destination, |
| Line 1665 ip_dooptions(struct mbuf *m) |
|
| Line 1660 ip_dooptions(struct mbuf *m) |
|
| (u_char *)ip; |
(u_char *)ip; |
| goto bad; |
goto bad; |
| } |
} |
| memcpy(&ipaddr.sin_addr, cp0, |
bcopy(cp0, &ipaddr.sin_addr, |
| sizeof(struct in_addr)); |
sizeof(struct in_addr)); |
| if (ifatoia(ifa_ifwithaddr(sintosa(&ipaddr))) |
if (ifatoia(ifa_ifwithaddr(sintosa(&ipaddr))) |
| == NULL) |
== NULL) |
| Line 1739 save_rte(u_char *option, struct in_addr |
|
| Line 1734 save_rte(u_char *option, struct in_addr |
|
| #endif /* 0 */ |
#endif /* 0 */ |
| if (olen > sizeof(ip_srcrt) - (1 + sizeof(dst))) |
if (olen > sizeof(ip_srcrt) - (1 + sizeof(dst))) |
| return; |
return; |
| memcpy((void *)ip_srcrt.srcopt, (void *)option, olen); |
bcopy((void *)option, (void *)ip_srcrt.srcopt, olen); |
| ip_nhops = (olen - IPOPT_OFFSET - 1) / sizeof(struct in_addr); |
ip_nhops = (olen - IPOPT_OFFSET - 1) / sizeof(struct in_addr); |
| ip_srcrt.dst = dst; |
ip_srcrt.dst = dst; |
| } |
} |
| Line 2057 ip_savecontrol(struct inpcb *inp, struct |
|
| Line 2052 ip_savecontrol(struct inpcb *inp, struct |
|
| struct mbuf *m) |
struct mbuf *m) |
| { |
{ |
| |
|
| if (inp->inp_socket->so_options & SO_TIMESTAMP |
if (inp->inp_socket->so_options & SO_TIMESTAMP) { |
| #ifdef SO_OTIMESTAMP |
|
| || inp->inp_socket->so_options & SO_OTIMESTAMP |
|
| #endif |
|
| ) { |
|
| struct timeval tv; |
struct timeval tv; |
| |
|
| microtime(&tv); |
microtime(&tv); |
| #ifdef SO_OTIMESTAMP |
|
| if (inp->inp_socket->so_options & SO_OTIMESTAMP) { |
|
| struct timeval50 tv50; |
|
| timeval_to_timeval50(&tv, &tv50); |
|
| *mp = sbcreatecontrol((void *) &tv50, sizeof(tv50), |
|
| SCM_OTIMESTAMP, SOL_SOCKET); |
|
| } else |
|
| #endif |
|
| *mp = sbcreatecontrol((void *) &tv, sizeof(tv), |
*mp = sbcreatecontrol((void *) &tv, sizeof(tv), |
| SCM_TIMESTAMP, SOL_SOCKET); |
SCM_TIMESTAMP, SOL_SOCKET); |
| if (*mp) |
if (*mp) |
| Line 2136 sysctl_net_inet_ip_forwsrcrt(SYSCTLFN_AR |
|
| Line 2119 sysctl_net_inet_ip_forwsrcrt(SYSCTLFN_AR |
|
| if (error || newp == NULL) |
if (error || newp == NULL) |
| return (error); |
return (error); |
| |
|
| error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_FORWSRCRT, |
if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_FORWSRCRT, |
| 0, NULL, NULL, NULL); |
0, NULL, NULL, NULL)) |
| if (error) |
return (EPERM); |
| return (error); |
|
| |
|
| ip_forwsrcrt = tmp; |
ip_forwsrcrt = tmp; |
| |
|