summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormelifaro <melifaro@FreeBSD.org>2015-08-08 15:58:35 +0000
committermelifaro <melifaro@FreeBSD.org>2015-08-08 15:58:35 +0000
commita915efe931e38b77fbd211a1b4776f7d8476661c (patch)
treef62740b5af9e3598f63fe19316899ed1aca803a5
parent59430835c25e6455228f112de2385eb73d2b65f2 (diff)
downloadFreeBSD-src-a915efe931e38b77fbd211a1b4776f7d8476661c.zip
FreeBSD-src-a915efe931e38b77fbd211a1b4776f7d8476661c.tar.gz
Simplify ip[6] simploop:
Do not pass 'dst' sockaddr to ip[6]_mloopback: - We have explicit check for AF_INET in ip_output() - We assume ip header inside passed mbuf in ip_mloopback - We assume ip6 header inside passed mbuf in ip6_mloopback
-rw-r--r--sys/netinet/ip_output.c19
-rw-r--r--sys/netinet6/ip6_mroute.c11
-rw-r--r--sys/netinet6/ip6_output.c6
-rw-r--r--sys/netinet6/ip6_var.h2
4 files changed, 11 insertions, 27 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 086a8c9..557458a 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -99,8 +99,7 @@ SYSCTL_INT(_net_inet_ip, OID_AUTO, mbuf_frag_size, CTLFLAG_RW,
&mbuf_frag_size, 0, "Fragment outgoing mbufs to this size");
#endif
-static void ip_mloopback
- (struct ifnet *, struct mbuf *, struct sockaddr_in *, int);
+static void ip_mloopback(struct ifnet *, const struct mbuf *, int);
extern int in_mcast_loop;
@@ -446,7 +445,7 @@ again:
* thus deferring a hash lookup and mutex acquisition
* at the expense of a cheap copy using m_copym().
*/
- ip_mloopback(ifp, m, dst, hlen);
+ ip_mloopback(ifp, m, hlen);
} else {
/*
* If we are acting as a multicast router, perform
@@ -1359,10 +1358,9 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt)
* replicating that code here.
*/
static void
-ip_mloopback(struct ifnet *ifp, struct mbuf *m, struct sockaddr_in *dst,
- int hlen)
+ip_mloopback(struct ifnet *ifp, const struct mbuf *m, int hlen)
{
- register struct ip *ip;
+ struct ip *ip;
struct mbuf *copym;
/*
@@ -1388,13 +1386,6 @@ ip_mloopback(struct ifnet *ifp, struct mbuf *m, struct sockaddr_in *dst,
ip = mtod(copym, struct ip *);
ip->ip_sum = 0;
ip->ip_sum = in_cksum(copym, hlen);
-#if 1 /* XXX */
- if (dst->sin_family != AF_INET) {
- printf("ip_mloopback: bad address family %d\n",
- dst->sin_family);
- dst->sin_family = AF_INET;
- }
-#endif
- if_simloop(ifp, copym, dst->sin_family, 0);
+ if_simloop(ifp, copym, AF_INET, 0);
}
}
diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c
index a2f9a7c..f560dc5 100644
--- a/sys/netinet6/ip6_mroute.c
+++ b/sys/netinet6/ip6_mroute.c
@@ -1583,15 +1583,8 @@ phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
* If configured to loop back multicasts by default,
* loop back a copy now.
*/
- if (in6_mcast_loop) {
- struct sockaddr_in6 dst6;
-
- bzero(&dst6, sizeof(dst6));
- dst6.sin6_len = sizeof(struct sockaddr_in6);
- dst6.sin6_family = AF_INET6;
- dst6.sin6_addr = ip6->ip6_dst;
- ip6_mloopback(ifp, m, &dst6);
- }
+ if (in6_mcast_loop)
+ ip6_mloopback(ifp, m);
/*
* Put the packet into the sending queue of the outgoing interface
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index d671951..49e6090 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -662,7 +662,7 @@ again:
* thus deferring a hash lookup and lock acquisition
* at the expense of an m_copym().
*/
- ip6_mloopback(ifp, m, dst);
+ ip6_mloopback(ifp, m);
} else {
/*
* If we are acting as a multicast router, perform
@@ -2883,7 +2883,7 @@ ip6_setpktopt(int optname, u_char *buf, int len, struct ip6_pktopts *opt,
* pointer that might NOT be &loif -- easier than replicating that code here.
*/
void
-ip6_mloopback(struct ifnet *ifp, struct mbuf *m, struct sockaddr_in6 *dst)
+ip6_mloopback(struct ifnet *ifp, const struct mbuf *m)
{
struct mbuf *copym;
struct ip6_hdr *ip6;
@@ -2915,7 +2915,7 @@ ip6_mloopback(struct ifnet *ifp, struct mbuf *m, struct sockaddr_in6 *dst)
CSUM_PSEUDO_HDR;
copym->m_pkthdr.csum_data = 0xffff;
}
- (void)if_simloop(ifp, copym, dst->sin6_family, 0);
+ if_simloop(ifp, copym, AF_INET6, 0);
}
/*
diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h
index 292d1a5..4bbdd16 100644
--- a/sys/netinet6/ip6_var.h
+++ b/sys/netinet6/ip6_var.h
@@ -373,7 +373,7 @@ int ip6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
void ip6_forward(struct mbuf *, int);
-void ip6_mloopback(struct ifnet *, struct mbuf *, struct sockaddr_in6 *);
+void ip6_mloopback(struct ifnet *, const struct mbuf *);
int ip6_output(struct mbuf *, struct ip6_pktopts *,
struct route_in6 *,
int,
OpenPOWER on IntegriCloud