PERFORCE change 167411 for review
Bjoern A. Zeeb
bz at FreeBSD.org
Sun Aug 16 19:32:28 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=167411
Change 167411 by bz at bz_zoo on 2009/08/16 19:32:08
- Rather than returning directly make a copy of the mbuf and leave
the original for the routing socket to possibly loop it back
to other listeners.
- Only adjust our local copy that we send to send_output_hook, which
will be responsible to make sure the mbuf will be freed.
Affected files ...
.. //depot/projects/soc2009/anchie_send/src/sys/net/rtsock.c#16 edit
Differences ...
==== //depot/projects/soc2009/anchie_send/src/sys/net/rtsock.c#16 (text+ko) ====
@@ -526,26 +526,41 @@
printf("RTM_SND!\n");
switch (rtm->rtm_seq) {
+ struct mbuf *n;
+
case RTM_SND_IN:
ifp = ifnet_byindex(rtm->rtm_index);
- if (ifp) {
- m_adj(m, sizeof (struct rt_msghdr));
- printf("rtm->rtm_index = %d\n", rtm->rtm_index);
- send_output_hook(m, ifp, SND_IN);
- } else {
- printf("route_output: ifp == NULL");
+ if (!ifp) {
+ printf("%s: RTM_SND_IN ifp == NULL", __func__);
+ senderr(EINVAL);
+ }
+ if ((n = m_dup(m, M_DONTWAIT)) == NULL) {
+ printf("%s: RTM_SND_IN n == NULL", __func__);
+ senderr(ENOBUFS);
}
- return (0);
+ m_adj(n, sizeof(struct rt_msghdr));
+ printf("%s: RTM_SND_IN ifp=%p(%s), mbuf=%p\n",
+ __func__, ifp, ifp->if_xname, n);
+ error = send_output_hook(n, ifp, SND_IN);
+ if (error)
+ senderr(error);
break;
case RTM_SND_OUT:
ifp = ifnet_byindex(rtm->rtm_index);
- if (ifp) {
- m_adj(m, sizeof (struct rt_msghdr));
- printf("if_index = %u\n", ifp->if_index);
- send_output_hook(m, ifp, SND_OUT);
- } else
- printf("route_output: ifp == NULL");
- return (0);
+ if (!ifp) {
+ printf("%s: RTM_SND_OUT ifp == NULL", __func__);
+ senderr(EINVAL);
+ }
+ if ((n = m_dup(m, M_DONTWAIT)) == NULL) {
+ printf("%s: RTM_SND_OUT n == NULL", __func__);
+ senderr(ENOBUFS);
+ }
+ m_adj(n, sizeof(struct rt_msghdr));
+ printf("%s: RTM_SND_OUT ifp=%p(%s), mbuf=%p\n",
+ __func__, ifp, ifp->if_xname, n);
+ error = send_output_hook(n, ifp, SND_OUT);
+ if (error)
+ senderr(error);
break;
}
More information about the p4-projects
mailing list