Back out some style changes. They are not urgent,
I will put them back in after 5.0 is out. Requested by: sam Approved by: re
This commit is contained in:
parent
b375c9ec2c
commit
032dcc7680
@ -63,9 +63,11 @@ static u_long raw_recvspace = RAWRCVQ;
|
|||||||
* of buffer space for the socket.
|
* of buffer space for the socket.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
raw_attach(struct socket *so, int proto)
|
raw_attach(so, proto)
|
||||||
|
register struct socket *so;
|
||||||
|
int proto;
|
||||||
{
|
{
|
||||||
struct rawcb *rp = sotorawcb(so);
|
register struct rawcb *rp = sotorawcb(so);
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -90,7 +92,8 @@ raw_attach(struct socket *so, int proto)
|
|||||||
* socket resources.
|
* socket resources.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
raw_detach(struct rawcb *rp)
|
raw_detach(rp)
|
||||||
|
register struct rawcb *rp;
|
||||||
{
|
{
|
||||||
struct socket *so = rp->rcb_socket;
|
struct socket *so = rp->rcb_socket;
|
||||||
|
|
||||||
@ -109,7 +112,8 @@ raw_detach(struct rawcb *rp)
|
|||||||
* Disconnect and possibly release resources.
|
* Disconnect and possibly release resources.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
raw_disconnect(struct rawcb *rp)
|
raw_disconnect(rp)
|
||||||
|
struct rawcb *rp;
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef notdef
|
#ifdef notdef
|
||||||
@ -125,7 +129,9 @@ raw_disconnect(struct rawcb *rp)
|
|||||||
#include <sys/mbuf.h>
|
#include <sys/mbuf.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
raw_bind(struct socket *so, struct mbuf *nam)
|
raw_bind(so, nam)
|
||||||
|
register struct socket *so;
|
||||||
|
struct mbuf *nam;
|
||||||
{
|
{
|
||||||
struct sockaddr *addr = mtod(nam, struct sockaddr *);
|
struct sockaddr *addr = mtod(nam, struct sockaddr *);
|
||||||
register struct rawcb *rp;
|
register struct rawcb *rp;
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
* Initialize raw connection block q.
|
* Initialize raw connection block q.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
raw_init(void)
|
raw_init()
|
||||||
{
|
{
|
||||||
LIST_INIT(&rawcb_list);
|
LIST_INIT(&rawcb_list);
|
||||||
}
|
}
|
||||||
@ -65,15 +65,17 @@ raw_init(void)
|
|||||||
* Raw protocol interface.
|
* Raw protocol interface.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
raw_input(struct mbuf *m0, struct sockproto *proto,
|
raw_input(m0, proto, src, dst)
|
||||||
struct sockaddr *src, struct sockaddr *dst)
|
struct mbuf *m0;
|
||||||
|
register struct sockproto *proto;
|
||||||
|
struct sockaddr *src, *dst;
|
||||||
{
|
{
|
||||||
struct rawcb *rp;
|
register struct rawcb *rp;
|
||||||
struct mbuf *m = m0;
|
register struct mbuf *m = m0;
|
||||||
int sockets = 0;
|
register int sockets = 0;
|
||||||
struct socket *last;
|
struct socket *last;
|
||||||
|
|
||||||
last = NULL;
|
last = 0;
|
||||||
LIST_FOREACH(rp, &rawcb_list, list) {
|
LIST_FOREACH(rp, &rawcb_list, list) {
|
||||||
if (rp->rcb_proto.sp_family != proto->sp_family)
|
if (rp->rcb_proto.sp_family != proto->sp_family)
|
||||||
continue;
|
continue;
|
||||||
@ -88,18 +90,18 @@ raw_input(struct mbuf *m0, struct sockproto *proto,
|
|||||||
* Note that if the lengths are not the same
|
* Note that if the lengths are not the same
|
||||||
* the comparison will fail at the first byte.
|
* the comparison will fail at the first byte.
|
||||||
*/
|
*/
|
||||||
#define equal(a1, a2) (bcmp((caddr_t)(a1), (caddr_t)(a2), a1->sa_len) == 0)
|
#define equal(a1, a2) \
|
||||||
|
(bcmp((caddr_t)(a1), (caddr_t)(a2), a1->sa_len) == 0)
|
||||||
if (rp->rcb_laddr && !equal(rp->rcb_laddr, dst))
|
if (rp->rcb_laddr && !equal(rp->rcb_laddr, dst))
|
||||||
continue;
|
continue;
|
||||||
if (rp->rcb_faddr && !equal(rp->rcb_faddr, src))
|
if (rp->rcb_faddr && !equal(rp->rcb_faddr, src))
|
||||||
continue;
|
continue;
|
||||||
if (last) {
|
if (last) {
|
||||||
struct mbuf *n = m_copypacket(m, M_DONTWAIT);
|
struct mbuf *n;
|
||||||
|
n = m_copy(m, 0, (int)M_COPYALL);
|
||||||
if (n) {
|
if (n) {
|
||||||
if (sbappendaddr(&last->so_rcv, src,
|
if (sbappendaddr(&last->so_rcv, src,
|
||||||
n, NULL) == 0)
|
n, (struct mbuf *)0) == 0)
|
||||||
/* should notify about lost packet */
|
/* should notify about lost packet */
|
||||||
m_freem(n);
|
m_freem(n);
|
||||||
else {
|
else {
|
||||||
@ -111,7 +113,8 @@ raw_input(struct mbuf *m0, struct sockproto *proto,
|
|||||||
last = rp->rcb_socket;
|
last = rp->rcb_socket;
|
||||||
}
|
}
|
||||||
if (last) {
|
if (last) {
|
||||||
if (sbappendaddr(&last->so_rcv, src, m, NULL) == 0)
|
if (sbappendaddr(&last->so_rcv, src,
|
||||||
|
m, (struct mbuf *)0) == 0)
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
else {
|
else {
|
||||||
sorwakeup(last);
|
sorwakeup(last);
|
||||||
@ -123,7 +126,10 @@ raw_input(struct mbuf *m0, struct sockproto *proto,
|
|||||||
|
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
void
|
void
|
||||||
raw_ctlinput(int cmd, struct sockaddr *arg, void *dummy)
|
raw_ctlinput(cmd, arg, dummy)
|
||||||
|
int cmd;
|
||||||
|
struct sockaddr *arg;
|
||||||
|
void *dummy;
|
||||||
{
|
{
|
||||||
|
|
||||||
if (cmd < 0 || cmd > PRC_NCMDS)
|
if (cmd < 0 || cmd > PRC_NCMDS)
|
||||||
@ -193,8 +199,9 @@ raw_udisconnect(struct socket *so)
|
|||||||
|
|
||||||
if (rp == 0)
|
if (rp == 0)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if (rp->rcb_faddr == 0)
|
if (rp->rcb_faddr == 0) {
|
||||||
return ENOTCONN;
|
return ENOTCONN;
|
||||||
|
}
|
||||||
raw_disconnect(rp);
|
raw_disconnect(rp);
|
||||||
soisdisconnected(so);
|
soisdisconnected(so);
|
||||||
return 0;
|
return 0;
|
||||||
@ -209,8 +216,9 @@ raw_upeeraddr(struct socket *so, struct sockaddr **nam)
|
|||||||
|
|
||||||
if (rp == 0)
|
if (rp == 0)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if (rp->rcb_faddr == 0)
|
if (rp->rcb_faddr == 0) {
|
||||||
return ENOTCONN;
|
return ENOTCONN;
|
||||||
|
}
|
||||||
*nam = dup_sockaddr(rp->rcb_faddr, 1);
|
*nam = dup_sockaddr(rp->rcb_faddr, 1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,8 @@
|
|||||||
|
|
||||||
static MALLOC_DEFINE(M_IGMP, "igmp", "igmp state");
|
static MALLOC_DEFINE(M_IGMP, "igmp", "igmp state");
|
||||||
|
|
||||||
static struct router_info *find_rti(struct ifnet *ifp);
|
static struct router_info *
|
||||||
|
find_rti(struct ifnet *ifp);
|
||||||
|
|
||||||
static struct igmpstat igmpstat;
|
static struct igmpstat igmpstat;
|
||||||
|
|
||||||
@ -92,7 +93,7 @@ static struct router_info *Head;
|
|||||||
static void igmp_sendpkt(struct in_multi *, int, unsigned long);
|
static void igmp_sendpkt(struct in_multi *, int, unsigned long);
|
||||||
|
|
||||||
void
|
void
|
||||||
igmp_init(void)
|
igmp_init()
|
||||||
{
|
{
|
||||||
struct ipoption *ra;
|
struct ipoption *ra;
|
||||||
|
|
||||||
@ -120,9 +121,10 @@ igmp_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct router_info *
|
static struct router_info *
|
||||||
find_rti(struct ifnet *ifp)
|
find_rti(ifp)
|
||||||
|
struct ifnet *ifp;
|
||||||
{
|
{
|
||||||
struct router_info *rti = Head;
|
register struct router_info *rti = Head;
|
||||||
|
|
||||||
#ifdef IGMP_DEBUG
|
#ifdef IGMP_DEBUG
|
||||||
printf("[igmp.c, _find_rti] --> entering \n");
|
printf("[igmp.c, _find_rti] --> entering \n");
|
||||||
@ -149,16 +151,18 @@ find_rti(struct ifnet *ifp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
igmp_input(struct mbuf *m, int off)
|
igmp_input(m, off)
|
||||||
|
register struct mbuf *m;
|
||||||
|
int off;
|
||||||
{
|
{
|
||||||
int iphlen = off;
|
register int iphlen = off;
|
||||||
struct igmp *igmp;
|
register struct igmp *igmp;
|
||||||
struct ip *ip;
|
register struct ip *ip;
|
||||||
int igmplen;
|
register int igmplen;
|
||||||
struct ifnet *ifp = m->m_pkthdr.rcvif;
|
register struct ifnet *ifp = m->m_pkthdr.rcvif;
|
||||||
int minlen;
|
register int minlen;
|
||||||
struct in_multi *inm;
|
register struct in_multi *inm;
|
||||||
struct in_ifaddr *ia;
|
register struct in_ifaddr *ia;
|
||||||
struct in_multistep step;
|
struct in_multistep step;
|
||||||
struct router_info *rti;
|
struct router_info *rti;
|
||||||
|
|
||||||
@ -341,7 +345,8 @@ igmp_input(struct mbuf *m, int off)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
igmp_joingroup(struct in_multi *inm)
|
igmp_joingroup(inm)
|
||||||
|
struct in_multi *inm;
|
||||||
{
|
{
|
||||||
int s = splnet();
|
int s = splnet();
|
||||||
|
|
||||||
@ -361,7 +366,8 @@ igmp_joingroup(struct in_multi *inm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
igmp_leavegroup(struct in_multi *inm)
|
igmp_leavegroup(inm)
|
||||||
|
struct in_multi *inm;
|
||||||
{
|
{
|
||||||
if (inm->inm_state == IGMP_IREPORTEDLAST &&
|
if (inm->inm_state == IGMP_IREPORTEDLAST &&
|
||||||
inm->inm_addr.s_addr != igmp_all_hosts_group &&
|
inm->inm_addr.s_addr != igmp_all_hosts_group &&
|
||||||
@ -371,9 +377,9 @@ igmp_leavegroup(struct in_multi *inm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
igmp_fasttimo(void)
|
igmp_fasttimo()
|
||||||
{
|
{
|
||||||
struct in_multi *inm;
|
register struct in_multi *inm;
|
||||||
struct in_multistep step;
|
struct in_multistep step;
|
||||||
int s;
|
int s;
|
||||||
|
|
||||||
@ -403,10 +409,10 @@ igmp_fasttimo(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
igmp_slowtimo(void)
|
igmp_slowtimo()
|
||||||
{
|
{
|
||||||
int s = splnet();
|
int s = splnet();
|
||||||
struct router_info *rti = Head;
|
register struct router_info *rti = Head;
|
||||||
|
|
||||||
#ifdef IGMP_DEBUG
|
#ifdef IGMP_DEBUG
|
||||||
printf("[igmp.c,_slowtimo] -- > entering \n");
|
printf("[igmp.c,_slowtimo] -- > entering \n");
|
||||||
@ -426,13 +432,13 @@ igmp_slowtimo(void)
|
|||||||
splx(s);
|
splx(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* XXX fix this static var when we remove the network code from Giant.
|
|
||||||
*/
|
|
||||||
static struct route igmprt;
|
static struct route igmprt;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
igmp_sendpkt(struct in_multi *inm, int type, unsigned long addr)
|
igmp_sendpkt(inm, type, addr)
|
||||||
|
struct in_multi *inm;
|
||||||
|
int type;
|
||||||
|
unsigned long addr;
|
||||||
{
|
{
|
||||||
struct mbuf *m;
|
struct mbuf *m;
|
||||||
struct igmp *igmp;
|
struct igmp *igmp;
|
||||||
|
@ -118,10 +118,10 @@ void (*ip_rsvp_force_done)(struct socket *);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize raw connection block queue.
|
* Initialize raw connection block q.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
rip_init(void)
|
rip_init()
|
||||||
{
|
{
|
||||||
INP_INFO_LOCK_INIT(&ripcbinfo, "rip");
|
INP_INFO_LOCK_INIT(&ripcbinfo, "rip");
|
||||||
LIST_INIT(&ripcb);
|
LIST_INIT(&ripcb);
|
||||||
@ -138,22 +138,19 @@ rip_init(void)
|
|||||||
uma_zone_set_max(ripcbinfo.ipi_zone, maxsockets);
|
uma_zone_set_max(ripcbinfo.ipi_zone, maxsockets);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* XXX ripsrc is modified in rip_input, so we must be fix this
|
|
||||||
* when we want to make this code smp-friendly.
|
|
||||||
*/
|
|
||||||
static struct sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET };
|
static struct sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup generic address and protocol structures
|
* Setup generic address and protocol structures
|
||||||
* for raw_input routine, then pass them along with
|
* for raw_input routine, then pass them along with
|
||||||
* mbuf chain.
|
* mbuf chain.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
rip_input(struct mbuf *m, int off)
|
rip_input(m, off)
|
||||||
|
struct mbuf *m;
|
||||||
|
int off;
|
||||||
{
|
{
|
||||||
struct ip *ip = mtod(m, struct ip *);
|
register struct ip *ip = mtod(m, struct ip *);
|
||||||
struct inpcb *inp;
|
register struct inpcb *inp;
|
||||||
struct inpcb *last = 0;
|
struct inpcb *last = 0;
|
||||||
struct mbuf *opts = 0;
|
struct mbuf *opts = 0;
|
||||||
int proto = ip->ip_p;
|
int proto = ip->ip_p;
|
||||||
@ -166,14 +163,14 @@ rip_input(struct mbuf *m, int off)
|
|||||||
#endif
|
#endif
|
||||||
if (inp->inp_ip_p && inp->inp_ip_p != proto)
|
if (inp->inp_ip_p && inp->inp_ip_p != proto)
|
||||||
continue;
|
continue;
|
||||||
if (inp->inp_laddr.s_addr != INADDR_ANY &&
|
if (inp->inp_laddr.s_addr &&
|
||||||
inp->inp_laddr.s_addr != ip->ip_dst.s_addr)
|
inp->inp_laddr.s_addr != ip->ip_dst.s_addr)
|
||||||
continue;
|
continue;
|
||||||
if (inp->inp_faddr.s_addr != INADDR_ANY &&
|
if (inp->inp_faddr.s_addr &&
|
||||||
inp->inp_faddr.s_addr != ip->ip_src.s_addr)
|
inp->inp_faddr.s_addr != ip->ip_src.s_addr)
|
||||||
continue;
|
continue;
|
||||||
if (last) {
|
if (last) {
|
||||||
struct mbuf *n = m_copypacket(m, M_DONTWAIT);
|
struct mbuf *n = m_copy(m, 0, (int)M_COPYALL);
|
||||||
int policyfail = 0;
|
int policyfail = 0;
|
||||||
|
|
||||||
if (n != NULL) {
|
if (n != NULL) {
|
||||||
@ -268,10 +265,13 @@ rip_input(struct mbuf *m, int off)
|
|||||||
* Tack on options user may have setup with control call.
|
* Tack on options user may have setup with control call.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
rip_output(struct mbuf *m, struct socket *so, u_long dst)
|
rip_output(m, so, dst)
|
||||||
|
struct mbuf *m;
|
||||||
|
struct socket *so;
|
||||||
|
u_long dst;
|
||||||
{
|
{
|
||||||
struct ip *ip;
|
register struct ip *ip;
|
||||||
struct inpcb *inp = sotoinpcb(so);
|
register struct inpcb *inp = sotoinpcb(so);
|
||||||
int flags = (so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST;
|
int flags = (so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST;
|
||||||
|
|
||||||
#ifdef MAC
|
#ifdef MAC
|
||||||
@ -330,7 +330,9 @@ rip_output(struct mbuf *m, struct socket *so, u_long dst)
|
|||||||
* Raw IP socket option processing.
|
* Raw IP socket option processing.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
rip_ctloutput(struct socket *so, struct sockopt *sopt)
|
rip_ctloutput(so, sopt)
|
||||||
|
struct socket *so;
|
||||||
|
struct sockopt *sopt;
|
||||||
{
|
{
|
||||||
struct inpcb *inp = sotoinpcb(so);
|
struct inpcb *inp = sotoinpcb(so);
|
||||||
int error, optval;
|
int error, optval;
|
||||||
@ -458,7 +460,10 @@ rip_ctloutput(struct socket *so, struct sockopt *sopt)
|
|||||||
* interface routes.
|
* interface routes.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
rip_ctlinput(int cmd, struct sockaddr *sa, void *vip)
|
rip_ctlinput(cmd, sa, vip)
|
||||||
|
int cmd;
|
||||||
|
struct sockaddr *sa;
|
||||||
|
void *vip;
|
||||||
{
|
{
|
||||||
struct in_ifaddr *ia;
|
struct in_ifaddr *ia;
|
||||||
struct ifnet *ifp;
|
struct ifnet *ifp;
|
||||||
@ -516,8 +521,7 @@ SYSCTL_INT(_net_inet_raw, OID_AUTO, maxdgram, CTLFLAG_RW,
|
|||||||
SYSCTL_INT(_net_inet_raw, OID_AUTO, recvspace, CTLFLAG_RW,
|
SYSCTL_INT(_net_inet_raw, OID_AUTO, recvspace, CTLFLAG_RW,
|
||||||
&rip_recvspace, 0, "Maximum incoming raw IP datagram size");
|
&rip_recvspace, 0, "Maximum incoming raw IP datagram size");
|
||||||
SYSCTL_INT(_net_inet_raw, OID_AUTO, olddiverterror, CTLFLAG_RW,
|
SYSCTL_INT(_net_inet_raw, OID_AUTO, olddiverterror, CTLFLAG_RW,
|
||||||
&rip_olddiverterror, 0,
|
&rip_olddiverterror, 0, "Return an error when creating an 'old' DIVERT socket");
|
||||||
"Return an error when creating an 'old' DIVERT socket");
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rip_attach(struct socket *so, int proto, struct thread *td)
|
rip_attach(struct socket *so, int proto, struct thread *td)
|
||||||
@ -536,9 +540,7 @@ rip_attach(struct socket *so, int proto, struct thread *td)
|
|||||||
|
|
||||||
/* To be removed before 5.2 */
|
/* To be removed before 5.2 */
|
||||||
if (rip_olddiverterror && proto == IPPROTO_OLD_DIVERT) {
|
if (rip_olddiverterror && proto == IPPROTO_OLD_DIVERT) {
|
||||||
printf("Old IPDIVERT program needs to be recompiled, "
|
printf("Old IPDIVERT program needs to be recompiled, or new IP proto 254 user needs sysctl net.inet.raw.olddiverterror=0\n");
|
||||||
"or new IP proto 254 user needs "
|
|
||||||
"sysctl net.inet.raw.olddiverterror=0\n");
|
|
||||||
return EPROTONOSUPPORT;
|
return EPROTONOSUPPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,7 +603,7 @@ rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
|||||||
|
|
||||||
if (TAILQ_EMPTY(&ifnet) || ((addr->sin_family != AF_INET) &&
|
if (TAILQ_EMPTY(&ifnet) || ((addr->sin_family != AF_INET) &&
|
||||||
(addr->sin_family != AF_IMPLINK)) ||
|
(addr->sin_family != AF_IMPLINK)) ||
|
||||||
(addr->sin_addr.s_addr != INADDR_ANY &&
|
(addr->sin_addr.s_addr &&
|
||||||
ifa_ifwithaddr((struct sockaddr *)addr) == 0))
|
ifa_ifwithaddr((struct sockaddr *)addr) == 0))
|
||||||
return EADDRNOTAVAIL;
|
return EADDRNOTAVAIL;
|
||||||
inp->inp_laddr = addr->sin_addr;
|
inp->inp_laddr = addr->sin_addr;
|
||||||
@ -638,7 +640,7 @@ rip_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
|
|||||||
struct mbuf *control, struct thread *td)
|
struct mbuf *control, struct thread *td)
|
||||||
{
|
{
|
||||||
struct inpcb *inp = sotoinpcb(so);
|
struct inpcb *inp = sotoinpcb(so);
|
||||||
u_long dst;
|
register u_long dst;
|
||||||
|
|
||||||
if (so->so_state & SS_ISCONNECTED) {
|
if (so->so_state & SS_ISCONNECTED) {
|
||||||
if (nam) {
|
if (nam) {
|
||||||
|
@ -98,15 +98,15 @@ static int udpcksum = 1;
|
|||||||
static int udpcksum = 0; /* XXX */
|
static int udpcksum = 0; /* XXX */
|
||||||
#endif
|
#endif
|
||||||
SYSCTL_INT(_net_inet_udp, UDPCTL_CHECKSUM, checksum, CTLFLAG_RW,
|
SYSCTL_INT(_net_inet_udp, UDPCTL_CHECKSUM, checksum, CTLFLAG_RW,
|
||||||
&udpcksum, 0, "");
|
&udpcksum, 0, "");
|
||||||
|
|
||||||
int log_in_vain; /* defaults to 0 */
|
int log_in_vain = 0;
|
||||||
SYSCTL_INT(_net_inet_udp, OID_AUTO, log_in_vain, CTLFLAG_RW,
|
SYSCTL_INT(_net_inet_udp, OID_AUTO, log_in_vain, CTLFLAG_RW,
|
||||||
&log_in_vain, 0, "Log all incoming UDP packets");
|
&log_in_vain, 0, "Log all incoming UDP packets");
|
||||||
|
|
||||||
static int blackhole; /* defaults to 0 */
|
static int blackhole = 0;
|
||||||
SYSCTL_INT(_net_inet_udp, OID_AUTO, blackhole, CTLFLAG_RW,
|
SYSCTL_INT(_net_inet_udp, OID_AUTO, blackhole, CTLFLAG_RW,
|
||||||
&blackhole, 0, "Do not send port unreachables for refused connects");
|
&blackhole, 0, "Do not send port unreachables for refused connects");
|
||||||
|
|
||||||
struct inpcbhead udb; /* from udp_var.h */
|
struct inpcbhead udb; /* from udp_var.h */
|
||||||
#define udb6 udb /* for KAME src sync over BSD*'s */
|
#define udb6 udb /* for KAME src sync over BSD*'s */
|
||||||
@ -120,12 +120,7 @@ struct udpstat udpstat; /* from udp_var.h */
|
|||||||
SYSCTL_STRUCT(_net_inet_udp, UDPCTL_STATS, stats, CTLFLAG_RW,
|
SYSCTL_STRUCT(_net_inet_udp, UDPCTL_STATS, stats, CTLFLAG_RW,
|
||||||
&udpstat, udpstat, "UDP statistics (struct udpstat, netinet/udp_var.h)");
|
&udpstat, udpstat, "UDP statistics (struct udpstat, netinet/udp_var.h)");
|
||||||
|
|
||||||
/*
|
|
||||||
* XXX warning, udp_in is not constant, so we need to fix this when
|
|
||||||
* we want to remove this code from under Giant
|
|
||||||
*/
|
|
||||||
static struct sockaddr_in udp_in = { sizeof(udp_in), AF_INET };
|
static struct sockaddr_in udp_in = { sizeof(udp_in), AF_INET };
|
||||||
|
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
struct udp_in6 {
|
struct udp_in6 {
|
||||||
struct sockaddr_in6 uin6_sin;
|
struct sockaddr_in6 uin6_sin;
|
||||||
@ -151,7 +146,7 @@ static int udp_output(struct inpcb *, struct mbuf *, struct sockaddr *,
|
|||||||
struct mbuf *, struct thread *);
|
struct mbuf *, struct thread *);
|
||||||
|
|
||||||
void
|
void
|
||||||
udp_init(void)
|
udp_init()
|
||||||
{
|
{
|
||||||
INP_INFO_LOCK_INIT(&udbinfo, "udp");
|
INP_INFO_LOCK_INIT(&udbinfo, "udp");
|
||||||
LIST_INIT(&udb);
|
LIST_INIT(&udb);
|
||||||
@ -165,12 +160,14 @@ udp_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
udp_input(struct mbuf *m, int off)
|
udp_input(m, off)
|
||||||
|
register struct mbuf *m;
|
||||||
|
int off;
|
||||||
{
|
{
|
||||||
int iphlen = off;
|
int iphlen = off;
|
||||||
struct ip *ip;
|
register struct ip *ip;
|
||||||
struct udphdr *uh;
|
register struct udphdr *uh;
|
||||||
struct inpcb *inp;
|
register struct inpcb *inp;
|
||||||
struct mbuf *opts = 0;
|
struct mbuf *opts = 0;
|
||||||
int len;
|
int len;
|
||||||
struct ip save_ip;
|
struct ip save_ip;
|
||||||
@ -314,7 +311,7 @@ udp_input(struct mbuf *m, int off)
|
|||||||
if (last != NULL) {
|
if (last != NULL) {
|
||||||
struct mbuf *n;
|
struct mbuf *n;
|
||||||
|
|
||||||
n = m_copypacket(m, M_DONTWAIT);
|
n = m_copy(m, 0, M_COPYALL);
|
||||||
if (n != NULL)
|
if (n != NULL)
|
||||||
udp_append(last, ip, n,
|
udp_append(last, ip, n,
|
||||||
iphlen +
|
iphlen +
|
||||||
@ -397,7 +394,9 @@ badunlocked:
|
|||||||
|
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
static void
|
static void
|
||||||
ip_2_ip6_hdr(struct ip6_hdr *ip6, struct ip *ip)
|
ip_2_ip6_hdr(ip6, ip)
|
||||||
|
struct ip6_hdr *ip6;
|
||||||
|
struct ip *ip;
|
||||||
{
|
{
|
||||||
bzero(ip6, sizeof(*ip6));
|
bzero(ip6, sizeof(*ip6));
|
||||||
|
|
||||||
@ -417,7 +416,11 @@ ip_2_ip6_hdr(struct ip6_hdr *ip6, struct ip *ip)
|
|||||||
* caller must properly init udp_ip6 and udp_in6 beforehand.
|
* caller must properly init udp_ip6 and udp_in6 beforehand.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
udp_append(struct inpcb *last, struct ip *ip, struct mbuf *n, int off)
|
udp_append(last, ip, n, off)
|
||||||
|
struct inpcb *last;
|
||||||
|
struct ip *ip;
|
||||||
|
struct mbuf *n;
|
||||||
|
int off;
|
||||||
{
|
{
|
||||||
struct sockaddr *append_sa;
|
struct sockaddr *append_sa;
|
||||||
struct mbuf *opts = 0;
|
struct mbuf *opts = 0;
|
||||||
@ -486,7 +489,9 @@ udp_append(struct inpcb *last, struct ip *ip, struct mbuf *n, int off)
|
|||||||
* just wake up so that he can collect error status.
|
* just wake up so that he can collect error status.
|
||||||
*/
|
*/
|
||||||
struct inpcb *
|
struct inpcb *
|
||||||
udp_notify(struct inpcb *inp, int errno)
|
udp_notify(inp, errno)
|
||||||
|
register struct inpcb *inp;
|
||||||
|
int errno;
|
||||||
{
|
{
|
||||||
inp->inp_socket->so_error = errno;
|
inp->inp_socket->so_error = errno;
|
||||||
sorwakeup(inp->inp_socket);
|
sorwakeup(inp->inp_socket);
|
||||||
@ -495,7 +500,10 @@ udp_notify(struct inpcb *inp, int errno)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
udp_ctlinput(int cmd, struct sockaddr *sa, void *vip)
|
udp_ctlinput(cmd, sa, vip)
|
||||||
|
int cmd;
|
||||||
|
struct sockaddr *sa;
|
||||||
|
void *vip;
|
||||||
{
|
{
|
||||||
struct ip *ip = vip;
|
struct ip *ip = vip;
|
||||||
struct udphdr *uh;
|
struct udphdr *uh;
|
||||||
@ -630,7 +638,7 @@ udp_pcblist(SYSCTL_HANDLER_ARGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SYSCTL_PROC(_net_inet_udp, UDPCTL_PCBLIST, pcblist, CTLFLAG_RD, 0, 0,
|
SYSCTL_PROC(_net_inet_udp, UDPCTL_PCBLIST, pcblist, CTLFLAG_RD, 0, 0,
|
||||||
udp_pcblist, "S,xinpcb", "List of active UDP sockets");
|
udp_pcblist, "S,xinpcb", "List of active UDP sockets");
|
||||||
|
|
||||||
static int
|
static int
|
||||||
udp_getcred(SYSCTL_HANDLER_ARGS)
|
udp_getcred(SYSCTL_HANDLER_ARGS)
|
||||||
@ -671,11 +679,15 @@ SYSCTL_PROC(_net_inet_udp, OID_AUTO, getcred,
|
|||||||
udp_getcred, "S,xucred", "Get the xucred of a UDP connection");
|
udp_getcred, "S,xucred", "Get the xucred of a UDP connection");
|
||||||
|
|
||||||
static int
|
static int
|
||||||
udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
|
udp_output(inp, m, addr, control, td)
|
||||||
struct mbuf *control, struct thread *td)
|
register struct inpcb *inp;
|
||||||
|
struct mbuf *m;
|
||||||
|
struct sockaddr *addr;
|
||||||
|
struct mbuf *control;
|
||||||
|
struct thread *td;
|
||||||
{
|
{
|
||||||
struct udpiphdr *ui;
|
register struct udpiphdr *ui;
|
||||||
int len = m->m_pkthdr.len;
|
register int len = m->m_pkthdr.len;
|
||||||
struct in_addr faddr, laddr;
|
struct in_addr faddr, laddr;
|
||||||
struct cmsghdr *cm;
|
struct cmsghdr *cm;
|
||||||
struct sockaddr_in *sin, src;
|
struct sockaddr_in *sin, src;
|
||||||
@ -835,11 +847,10 @@ release:
|
|||||||
}
|
}
|
||||||
|
|
||||||
u_long udp_sendspace = 9216; /* really max datagram size */
|
u_long udp_sendspace = 9216; /* really max datagram size */
|
||||||
|
/* 40 1K datagrams */
|
||||||
SYSCTL_INT(_net_inet_udp, UDPCTL_MAXDGRAM, maxdgram, CTLFLAG_RW,
|
SYSCTL_INT(_net_inet_udp, UDPCTL_MAXDGRAM, maxdgram, CTLFLAG_RW,
|
||||||
&udp_sendspace, 0, "Maximum outgoing UDP datagram size");
|
&udp_sendspace, 0, "Maximum outgoing UDP datagram size");
|
||||||
|
|
||||||
/* XXX having this conditional is just silly! */
|
|
||||||
u_long udp_recvspace = 40 * (1024 +
|
u_long udp_recvspace = 40 * (1024 +
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
sizeof(struct sockaddr_in6)
|
sizeof(struct sockaddr_in6)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user