Cosmetic: s/g_proto/sc_proto/. Remove superfluous parentheses and
curly braces.
This commit is contained in:
parent
dca2bdf5fa
commit
641edc65f1
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: if_gre.c,v 1.74 2006/11/16 01:33:40 christos Exp $ */
|
/* $NetBSD: if_gre.c,v 1.75 2006/11/16 22:26:35 dyoung Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.74 2006/11/16 01:33:40 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.75 2006/11/16 22:26:35 dyoung Exp $");
|
||||||
|
|
||||||
#include "opt_gre.h"
|
#include "opt_gre.h"
|
||||||
#include "opt_inet.h"
|
#include "opt_inet.h"
|
||||||
|
@ -193,7 +193,7 @@ gre_clone_create(struct if_clone *ifc, int unit)
|
||||||
sc->sc_if.if_ioctl = gre_ioctl;
|
sc->sc_if.if_ioctl = gre_ioctl;
|
||||||
sc->g_dst.s_addr = sc->g_src.s_addr = INADDR_ANY;
|
sc->g_dst.s_addr = sc->g_src.s_addr = INADDR_ANY;
|
||||||
sc->g_dstport = sc->g_srcport = 0;
|
sc->g_dstport = sc->g_srcport = 0;
|
||||||
sc->g_proto = IPPROTO_GRE;
|
sc->sc_proto = IPPROTO_GRE;
|
||||||
sc->sc_snd.ifq_maxlen = 256;
|
sc->sc_snd.ifq_maxlen = 256;
|
||||||
sc->sc_if.if_flags |= IFF_LINK0;
|
sc->sc_if.if_flags |= IFF_LINK0;
|
||||||
if_attach(&sc->sc_if);
|
if_attach(&sc->sc_if);
|
||||||
|
@ -381,7 +381,7 @@ gre_thread1(struct gre_softc *sc, struct lwp *l)
|
||||||
__func__);
|
__func__);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (sc->g_proto != IPPROTO_UDP) {
|
if (sc->sc_proto != IPPROTO_UDP) {
|
||||||
GRE_DPRINTF(sc, "%s: not udp; exiting\n", __func__);
|
GRE_DPRINTF(sc, "%s: not udp; exiting\n", __func__);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -471,7 +471,7 @@ gre_thread1(struct gre_softc *sc, struct lwp *l)
|
||||||
gre_sodestroy(&so);
|
gre_sodestroy(&so);
|
||||||
out:
|
out:
|
||||||
GRE_DPRINTF(sc, "%s: stopping\n", __func__);
|
GRE_DPRINTF(sc, "%s: stopping\n", __func__);
|
||||||
if (sc->g_proto == IPPROTO_UDP)
|
if (sc->sc_proto == IPPROTO_UDP)
|
||||||
ifp->if_flags &= ~IFF_RUNNING;
|
ifp->if_flags &= ~IFF_RUNNING;
|
||||||
while (!IF_IS_EMPTY(&sc->sc_snd)) {
|
while (!IF_IS_EMPTY(&sc->sc_snd)) {
|
||||||
IF_DEQUEUE(&sc->sc_snd, m);
|
IF_DEQUEUE(&sc->sc_snd, m);
|
||||||
|
@ -590,7 +590,7 @@ gre_input3(struct gre_softc *sc, struct mbuf *m, int hlen, u_char proto,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The output routine. Takes a packet and encapsulates it in the protocol
|
* The output routine. Takes a packet and encapsulates it in the protocol
|
||||||
* given by sc->g_proto. See also RFC 1701 and RFC 2004
|
* given by sc->sc_proto. See also RFC 1701 and RFC 2004
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
|
gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
|
||||||
|
@ -622,7 +622,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
|
||||||
|
|
||||||
m->m_flags &= ~(M_BCAST|M_MCAST);
|
m->m_flags &= ~(M_BCAST|M_MCAST);
|
||||||
|
|
||||||
switch (sc->g_proto) {
|
switch (sc->sc_proto) {
|
||||||
case IPPROTO_MOBILE:
|
case IPPROTO_MOBILE:
|
||||||
if (dst->sa_family == AF_INET) {
|
if (dst->sa_family == AF_INET) {
|
||||||
int msiz;
|
int msiz;
|
||||||
|
@ -709,7 +709,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (sc->g_proto) {
|
switch (sc->sc_proto) {
|
||||||
case IPPROTO_GRE:
|
case IPPROTO_GRE:
|
||||||
hlen = sizeof(struct greip);
|
hlen = sizeof(struct greip);
|
||||||
break;
|
break;
|
||||||
|
@ -729,7 +729,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (sc->g_proto) {
|
switch (sc->sc_proto) {
|
||||||
case IPPROTO_UDP:
|
case IPPROTO_UDP:
|
||||||
gh = mtod(m, struct gre_h *);
|
gh = mtod(m, struct gre_h *);
|
||||||
memset(gh, 0, sizeof(*gh));
|
memset(gh, 0, sizeof(*gh));
|
||||||
|
@ -749,11 +749,11 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
|
||||||
eip->ip_ttl = ip_gre_ttl;
|
eip->ip_ttl = ip_gre_ttl;
|
||||||
eip->ip_tos = ip_tos;
|
eip->ip_tos = ip_tos;
|
||||||
eip->ip_len = htons(m->m_pkthdr.len);
|
eip->ip_len = htons(m->m_pkthdr.len);
|
||||||
eip->ip_p = sc->g_proto;
|
eip->ip_p = sc->sc_proto;
|
||||||
break;
|
break;
|
||||||
case IPPROTO_MOBILE:
|
case IPPROTO_MOBILE:
|
||||||
eip = mtod(m, struct ip *);
|
eip = mtod(m, struct ip *);
|
||||||
eip->ip_p = sc->g_proto;
|
eip->ip_p = sc->sc_proto;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error = EPROTONOSUPPORT;
|
error = EPROTONOSUPPORT;
|
||||||
|
@ -765,7 +765,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
|
||||||
ifp->if_obytes += m->m_pkthdr.len;
|
ifp->if_obytes += m->m_pkthdr.len;
|
||||||
|
|
||||||
/* send it off */
|
/* send it off */
|
||||||
if (sc->g_proto == IPPROTO_UDP) {
|
if (sc->sc_proto == IPPROTO_UDP) {
|
||||||
if (IF_QFULL(&sc->sc_snd)) {
|
if (IF_QFULL(&sc->sc_snd)) {
|
||||||
IF_DROP(&sc->sc_snd);
|
IF_DROP(&sc->sc_snd);
|
||||||
error = ENOBUFS;
|
error = ENOBUFS;
|
||||||
|
@ -795,7 +795,7 @@ gre_kick(struct gre_softc *sc)
|
||||||
int rc;
|
int rc;
|
||||||
struct ifnet *ifp = &sc->sc_if;
|
struct ifnet *ifp = &sc->sc_if;
|
||||||
|
|
||||||
if (sc->g_proto == IPPROTO_UDP && (ifp->if_flags & IFF_UP) == IFF_UP &&
|
if (sc->sc_proto == IPPROTO_UDP && (ifp->if_flags & IFF_UP) == IFF_UP &&
|
||||||
!sc->sc_thread) {
|
!sc->sc_thread) {
|
||||||
sc->sc_thread = 1;
|
sc->sc_thread = 1;
|
||||||
rc = kthread_create1(gre_thread, (void *)sc, NULL,
|
rc = kthread_create1(gre_thread, (void *)sc, NULL,
|
||||||
|
@ -913,20 +913,20 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||||
case SIOCSIFDSTADDR:
|
case SIOCSIFDSTADDR:
|
||||||
break;
|
break;
|
||||||
case SIOCSIFFLAGS:
|
case SIOCSIFFLAGS:
|
||||||
oproto = sc->g_proto;
|
oproto = sc->sc_proto;
|
||||||
switch (ifr->ifr_flags & (IFF_LINK0|IFF_LINK2)) {
|
switch (ifr->ifr_flags & (IFF_LINK0|IFF_LINK2)) {
|
||||||
case IFF_LINK0|IFF_LINK2:
|
case IFF_LINK0|IFF_LINK2:
|
||||||
sc->g_proto = IPPROTO_UDP;
|
sc->sc_proto = IPPROTO_UDP;
|
||||||
if (oproto != IPPROTO_UDP)
|
if (oproto != IPPROTO_UDP)
|
||||||
ifp->if_flags &= ~IFF_RUNNING;
|
ifp->if_flags &= ~IFF_RUNNING;
|
||||||
error = gre_kick(sc);
|
error = gre_kick(sc);
|
||||||
break;
|
break;
|
||||||
case IFF_LINK0:
|
case IFF_LINK0:
|
||||||
sc->g_proto = IPPROTO_GRE;
|
sc->sc_proto = IPPROTO_GRE;
|
||||||
gre_wakeup(sc);
|
gre_wakeup(sc);
|
||||||
goto recompute;
|
goto recompute;
|
||||||
case 0:
|
case 0:
|
||||||
sc->g_proto = IPPROTO_MOBILE;
|
sc->sc_proto = IPPROTO_MOBILE;
|
||||||
gre_wakeup(sc);
|
gre_wakeup(sc);
|
||||||
goto recompute;
|
goto recompute;
|
||||||
}
|
}
|
||||||
|
@ -962,9 +962,9 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GRESPROTO:
|
case GRESPROTO:
|
||||||
oproto = sc->g_proto;
|
oproto = sc->sc_proto;
|
||||||
sc->g_proto = ifr->ifr_flags;
|
sc->sc_proto = ifr->ifr_flags;
|
||||||
switch (sc->g_proto) {
|
switch (sc->sc_proto) {
|
||||||
case IPPROTO_UDP:
|
case IPPROTO_UDP:
|
||||||
ifp->if_flags |= IFF_LINK0|IFF_LINK2;
|
ifp->if_flags |= IFF_LINK0|IFF_LINK2;
|
||||||
if (oproto != IPPROTO_UDP)
|
if (oproto != IPPROTO_UDP)
|
||||||
|
@ -984,7 +984,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GREGPROTO:
|
case GREGPROTO:
|
||||||
ifr->ifr_flags = sc->g_proto;
|
ifr->ifr_flags = sc->sc_proto;
|
||||||
break;
|
break;
|
||||||
case GRESADDRS:
|
case GRESADDRS:
|
||||||
case GRESADDRD:
|
case GRESADDRD:
|
||||||
|
@ -998,7 +998,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||||
sc->g_srcport = satosin(sa)->sin_port;
|
sc->g_srcport = satosin(sa)->sin_port;
|
||||||
}
|
}
|
||||||
if (cmd == GRESADDRD) {
|
if (cmd == GRESADDRD) {
|
||||||
if (sc->g_proto == IPPROTO_UDP &&
|
if (sc->sc_proto == IPPROTO_UDP &&
|
||||||
satosin(sa)->sin_port == 0) {
|
satosin(sa)->sin_port == 0) {
|
||||||
error = EINVAL;
|
error = EINVAL;
|
||||||
break;
|
break;
|
||||||
|
@ -1007,7 +1007,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||||
sc->g_dstport = satosin(sa)->sin_port;
|
sc->g_dstport = satosin(sa)->sin_port;
|
||||||
}
|
}
|
||||||
recompute:
|
recompute:
|
||||||
if (sc->g_proto == IPPROTO_UDP ||
|
if (sc->sc_proto == IPPROTO_UDP ||
|
||||||
(sc->g_src.s_addr != INADDR_ANY &&
|
(sc->g_src.s_addr != INADDR_ANY &&
|
||||||
sc->g_dst.s_addr != INADDR_ANY)) {
|
sc->g_dst.s_addr != INADDR_ANY)) {
|
||||||
if (sc->sc_fp != NULL) {
|
if (sc->sc_fp != NULL) {
|
||||||
|
@ -1018,7 +1018,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||||
RTFREE(sc->route.ro_rt);
|
RTFREE(sc->route.ro_rt);
|
||||||
sc->route.ro_rt = NULL;
|
sc->route.ro_rt = NULL;
|
||||||
}
|
}
|
||||||
if (sc->g_proto == IPPROTO_UDP)
|
if (sc->sc_proto == IPPROTO_UDP)
|
||||||
error = gre_kick(sc);
|
error = gre_kick(sc);
|
||||||
else if (gre_compute_route(sc) == 0)
|
else if (gre_compute_route(sc) == 0)
|
||||||
ifp->if_flags |= IFF_RUNNING;
|
ifp->if_flags |= IFF_RUNNING;
|
||||||
|
@ -1043,7 +1043,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||||
ifr->ifr_addr = *sa;
|
ifr->ifr_addr = *sa;
|
||||||
break;
|
break;
|
||||||
case GREDSOCK:
|
case GREDSOCK:
|
||||||
if (sc->g_proto != IPPROTO_UDP)
|
if (sc->sc_proto != IPPROTO_UDP)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if (sc->sc_fp != NULL) {
|
if (sc->sc_fp != NULL) {
|
||||||
closef(sc->sc_fp, l);
|
closef(sc->sc_fp, l);
|
||||||
|
@ -1052,7 +1052,7 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GRESSOCK:
|
case GRESSOCK:
|
||||||
if (sc->g_proto != IPPROTO_UDP)
|
if (sc->sc_proto != IPPROTO_UDP)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
/* getsock() will FILE_USE() the descriptor for us */
|
/* getsock() will FILE_USE() the descriptor for us */
|
||||||
if ((error = getsock(p->p_fd, (int)ifr->ifr_value, &fp)) != 0)
|
if ((error = getsock(p->p_fd, (int)ifr->ifr_value, &fp)) != 0)
|
||||||
|
@ -1117,11 +1117,11 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||||
si.sin_family = AF_INET;
|
si.sin_family = AF_INET;
|
||||||
si.sin_len = sizeof(struct sockaddr_in);
|
si.sin_len = sizeof(struct sockaddr_in);
|
||||||
si.sin_addr = sc->g_src;
|
si.sin_addr = sc->g_src;
|
||||||
if (sc->g_proto == IPPROTO_UDP)
|
if (sc->sc_proto == IPPROTO_UDP)
|
||||||
si.sin_port = sc->g_srcport;
|
si.sin_port = sc->g_srcport;
|
||||||
memcpy(&lifr->addr, &si, sizeof(si));
|
memcpy(&lifr->addr, &si, sizeof(si));
|
||||||
si.sin_addr = sc->g_dst;
|
si.sin_addr = sc->g_dst;
|
||||||
if (sc->g_proto == IPPROTO_UDP)
|
if (sc->sc_proto == IPPROTO_UDP)
|
||||||
si.sin_port = sc->g_dstport;
|
si.sin_port = sc->g_dstport;
|
||||||
memcpy(&lifr->dstaddr, &si, sizeof(si));
|
memcpy(&lifr->dstaddr, &si, sizeof(si));
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: ip_gre.c,v 1.42 2006/09/07 02:40:33 dogcow Exp $ */
|
/* $NetBSD: ip_gre.c,v 1.43 2006/11/16 22:26:36 dyoung Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: ip_gre.c,v 1.42 2006/09/07 02:40:33 dogcow Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: ip_gre.c,v 1.43 2006/11/16 22:26:36 dyoung Exp $");
|
||||||
|
|
||||||
#include "gre.h"
|
#include "gre.h"
|
||||||
#if NGRE > 0
|
#if NGRE > 0
|
||||||
|
@ -146,13 +146,13 @@ gre_input2(struct mbuf *m, int hlen, u_char proto)
|
||||||
|
|
||||||
if ((sc = gre_lookup(m, proto)) == NULL) {
|
if ((sc = gre_lookup(m, proto)) == NULL) {
|
||||||
/* No matching tunnel or tunnel is down. */
|
/* No matching tunnel or tunnel is down. */
|
||||||
return (0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->m_len < sizeof(*gip)) {
|
if (m->m_len < sizeof(*gip)) {
|
||||||
m = m_pullup(m, sizeof(*gip));
|
m = m_pullup(m, sizeof(*gip));
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return (ENOBUFS);
|
return ENOBUFS;
|
||||||
}
|
}
|
||||||
gip = mtod(m, const struct greip *);
|
gip = mtod(m, const struct greip *);
|
||||||
|
|
||||||
|
@ -240,9 +240,8 @@ gre_mobile_input(struct mbuf *m, ...)
|
||||||
if (IF_QFULL(ifq)) {
|
if (IF_QFULL(ifq)) {
|
||||||
IF_DROP(ifq);
|
IF_DROP(ifq);
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
} else {
|
} else
|
||||||
IF_ENQUEUE(ifq, m);
|
IF_ENQUEUE(ifq, m);
|
||||||
}
|
|
||||||
splx(s);
|
splx(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,14 +256,14 @@ gre_lookup(struct mbuf *m, u_int8_t proto)
|
||||||
|
|
||||||
for (sc = LIST_FIRST(&gre_softc_list); sc != NULL;
|
for (sc = LIST_FIRST(&gre_softc_list); sc != NULL;
|
||||||
sc = LIST_NEXT(sc, sc_list)) {
|
sc = LIST_NEXT(sc, sc_list)) {
|
||||||
if ((sc->g_dst.s_addr == ip->ip_src.s_addr) &&
|
if (sc->g_dst.s_addr == ip->ip_src.s_addr &&
|
||||||
(sc->g_src.s_addr == ip->ip_dst.s_addr) &&
|
sc->g_src.s_addr == ip->ip_dst.s_addr &&
|
||||||
(sc->g_proto == proto) &&
|
sc->sc_proto == proto &&
|
||||||
((sc->sc_if.if_flags & IFF_UP) != 0))
|
(sc->sc_if.if_flags & IFF_UP) != 0)
|
||||||
return (sc);
|
return sc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* if NGRE > 0 */
|
#endif /* if NGRE > 0 */
|
||||||
|
|
Loading…
Reference in New Issue