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
This commit is contained in:
Alexander V. Chernikov 2015-08-08 15:58:35 +00:00
parent b8a1f275ac
commit 331dff0737
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=286452
4 changed files with 11 additions and 27 deletions

View file

@ -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 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
* 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);
}
}

View file

@ -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

View file

@ -662,7 +662,7 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt,
* 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);
}
/*

View file

@ -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,