PERFORCE change 166165 for review
Ana Kukec
anchie at FreeBSD.org
Thu Jul 16 13:12:13 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=166165
Change 166165 by anchie at anchie_malimis on 2009/07/16 13:11:39
Processing of the incoming packet: ND packet goes to userspace through
the netinet6/send.c: send_input(); SEND packet comes back to kernel
through netinet6/send.c: send_output() which calls netinet6/nd6_nbr.c:
nd6_ns_input() (and other.. nd6_**_input() functions) and
icmp6_rip6_input().
Affected files ...
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#19 edit
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/proto.c#9 edit
.. //depot/projects/soc2009/anchie_send/src/sys/net/rtsock.c#9 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/send.c#18 edit
Differences ...
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#19 (text+ko) ====
@@ -157,6 +157,8 @@
}
snd_put_buf(b);
+
+ return;
}
void
@@ -234,7 +236,7 @@
int n;
if ((b = snd_get_buf()) == NULL) {
- return;
+ goto done;
}
pi = sbuff_data(b);
@@ -267,9 +269,14 @@
switch (ifan->ifan_what) {
case RTM_SND_IN:
applog(LOG_ERR, "RTM_SND_IN");
- /* n = RTM hdr + m as passed to nd6_ns_input() */
- b = (struct rt_msghdr *) &ifan[1];
- /* ToDo: Extract ifidx. */
+ /* n = RTM hdr + SEND message */
+ if (sbuff_pull(b, sizeof (struct rt_msghdr)) == NULL) {
+ DBG(&dbg_snd, "invalid pkt (not enough for rtm hedaer"); goto done;
+ }
+
+ pi->ifinfo = p;
+ pi->in = SND_IN;
+
snd_recv_pkt(b, p->ifidx, SND_IN);
break;
case RTM_SND_OUT:
==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/proto.c#9 (text+ko) ====
@@ -383,7 +383,11 @@
DBG(&dbg, "%s pkt (%d bytes)", drop ? "dropping" : "delivering",
pi->b->len);
+#if 0
os_specific_deliver_pkt(pi->os_pkt, pi->b, drop, 1);
+#endif
+ snd_deliver_pkt(pi->os_pkt, pi->b, drop, 1);
+
free(pi);
}
@@ -431,6 +435,7 @@
os_specific_deliver_pkt(pi->os_pkt, pi->b, drop, 1);
#endif
snd_deliver_pkt(pi->os_pkt, pi->b, drop, 1);
+
free(pi);
}
@@ -736,13 +741,12 @@
}
if (in) {
- /*
if (snd_is_lcl_cga(pi->cga, ifidx)) {
DBG(&dbg, "is local; don't need to check");
drop = 0;
goto done;
}
- */
+
if (snd_parse_opts(&pi->ndopts, sbuff_data(b), b->len) < 0) {
goto drop;
}
==== //depot/projects/soc2009/anchie_send/src/sys/net/rtsock.c#9 (text+ko) ====
@@ -524,12 +524,29 @@
case RTM_SND:
printf("RTM_SND!");
- m_adj(m, sizeof (struct rt_msghdr));
- printf("rtm->rtm_index = %d\n", rtm->rtm_index);
- ifp = ifnet_byindex(rtm->rtm_index);
- if (ifp)
- send_output_hook(m, ifp, SND_OUT);
- break;
+ struct if_announcemsghdr *ifan;
+ ifan = mtod(m, struct if_announcemsghdr *);
+
+ switch (ifan->ifan_what) {
+ case RTM_SND_IN:
+ ifp = ifnet_byindex(rtm->rtm_index);
+ m_adj(m, sizeof (struct rt_msghdr));
+ printf("rtm->rtm_index = %d\n", rtm->rtm_index);
+ if (ifp)
+ send_output_hook(m, ifp, SND_IN);
+ break;
+ case RTM_SND_OUT:
+ ifp = m->m_pkthdr.rcvif;
+ printf("rtm->rtm_index = %d\n", rtm->rtm_index);
+#if 0
+ ifp = ifnet_byindex(rtm->rtm_index);
+#endif
+ m_adj(m, sizeof (struct rt_msghdr));
+ if (ifp)
+ send_output_hook(m, ifp, SND_OUT);
+ break;
+ }
+
case RTM_ADD:
if (info.rti_info[RTAX_GATEWAY] == NULL)
senderr(EINVAL);
==== //depot/projects/soc2009/anchie_send/src/sys/netinet6/send.c#18 (text+ko) ====
@@ -22,6 +22,8 @@
{
struct ip6_hdr *ip6;
struct sockaddr_in6 *dst;
+ struct icmp6_hdr *icmp6
+ int icmp6len;
printf("send_output\n");
@@ -31,21 +33,38 @@
* Outgoing packets are sent out using if_output().
*/
- ip6 = mtod(m, struct ip6_hdr *);
- //struct in6_addr dst = ip6->ip6_dst;
- //dst = &ip6->ip6_dst;
+ switch (in) {
+ case SND_IN:
+ icmp6len = m->m_pkthdr.len - sizeof(struct ip6_hdr);
+ printf("send_output: m_pkthdr.len = %d\n", m->m_pkthdr.len);
+
+ icmp6 = (struct icmp6_hdr *)((caddr_t)ip6 + sizeof(struct ip6_hdr));
+ switch (icmp6->icmp6_code) {
+ case ND_NEIGHBOR_SOLICIT:
+ /* From icmp6.c: incpm6_input(). */
+ nd6_ns_input(m, sizeof(struct ip6_hdr), icmp6len);
+ break;
+ }
+
+ //icmp6_rip6_input(&m, *offp);
+
+ break;
+ case SND_OUT:
+ ip6 = mtod(m, struct ip6_hdr *);
- dst = malloc (2 * sizeof (struct sockaddr_in6), M_TEMP, M_NOWAIT);
- dst->sin6_len = sizeof(struct sockaddr_in6);
- dst->sin6_family = AF_INET6;
- dst->sin6_addr = ip6->ip6_dst;
+ dst = malloc (sizeof (struct sockaddr_in6), M_TEMP, M_NOWAIT);
+ dst->sin6_len = sizeof(struct sockaddr_in6);
+ dst->sin6_family = AF_INET6;
+ dst->sin6_addr = ip6->ip6_dst;
- /*
- * From nd6.c: nd6_output_lle().
- * ToFix: kernel panic: Duplicate free of item (mbuf).
- */
- return (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, NULL);
- //return (0);
+ /*
+ * From nd6.c: nd6_output_lle().
+ * ToFix: kernel panic: Duplicate free of item (mbuf).
+ */
+ return (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, NULL);
+ //return (0);
+ break;
+ }
}
static int
More information about the p4-projects
mailing list