==== //depot/projects/ethng/src/sys/netinet/if_ether.c#7 (text+ko) - //depot/projects/toestack/sys/netinet/if_ether.c#11 (text+ko) ==== content @@ -362,15 +362,17 @@ struct sockaddr_dl *sdl; int error; - if (m->m_flags & M_BCAST) { /* broadcast */ - (void)memcpy(desten, ifp->if_broadcastaddr, ifp->if_addrlen); - return (0); + if (m) { + if (m->m_flags & M_BCAST) { /* broadcast */ + (void)memcpy(desten, ifp->if_broadcastaddr, ifp->if_addrlen); + return (0); + } + if (m->m_flags & M_MCAST && ifp->if_type != IFT_ARCNET) {/* multicast */ + ETHER_MAP_IP_MULTICAST(&SIN(dst)->sin_addr, desten); + return (0); + } } - if (m->m_flags & M_MCAST && ifp->if_type != IFT_ARCNET) {/* multicast */ - ETHER_MAP_IP_MULTICAST(&SIN(dst)->sin_addr, desten); - return (0); - } - + if (rt0 != NULL) { error = rt_check(&rt, &rt0, dst); if (error) { @@ -413,7 +415,7 @@ sdl->sdl_family == AF_LINK && sdl->sdl_alen != 0) { bcopy(LLADDR(sdl), desten, sdl->sdl_alen); - + /* * If entry has an expiry time and it is approaching, * send an ARP request. @@ -449,10 +451,12 @@ * response yet. Replace the held mbuf with this * latest one. */ - if (la->la_hold) - m_freem(la->la_hold); - la->la_hold = m; - + if (m) { + if (la->la_hold) + m_freem(la->la_hold); + la->la_hold = m; + } + KASSERT(rt->rt_expire > 0, ("sending ARP request for static entry")); /* @@ -730,6 +734,7 @@ } (void)memcpy(LLADDR(sdl), ar_sha(ah), sdl->sdl_alen = ah->ar_hln); + /* * If we receive an arp from a token-ring station over * a token-ring nic then try to save the source @@ -772,6 +777,7 @@ la->la_preempt = arp_maxtries; hold = la->la_hold; la->la_hold = NULL; + EVENTHANDLER_INVOKE(route_event, RTEVENT_ARP_UPDATE, rt, NULL); RT_UNLOCK(rt); if (hold != NULL) (*ifp->if_output)(ifp, hold, rt_key(rt), rt); @@ -805,12 +811,12 @@ * over who claims what Ether address. */ if (rt->rt_ifp == ifp) { - rtfree(rt); + RTFREE_LOCKED(rt); goto drop; } (void)memcpy(ar_tha(ah), ar_sha(ah), ah->ar_hln); (void)memcpy(ar_sha(ah), enaddr, ah->ar_hln); - rtfree(rt); + RTFREE_LOCKED(rt); /* * Also check that the node which sent the ARP packet @@ -828,10 +834,10 @@ " from %s via %s, expecting %s\n", inet_ntoa(isaddr), ifp->if_xname, rt->rt_ifp->if_xname); - rtfree(rt); + RTFREE_LOCKED(rt); goto drop; } - rtfree(rt); + RTFREE_LOCKED(rt); #ifdef DEBUG_PROXY printf("arp: proxying for %s\n", @@ -936,12 +942,12 @@ } } -void -arp_ifinit(struct ifnet *ifp, struct ifaddr *ifa) +static __inline void +arp_ifinit_internal(struct ifnet *ifp, struct ifaddr *ifa, u_char *enaddr) { if (ntohl(IA_SIN(ifa)->sin_addr.s_addr) != INADDR_ANY) arprequest(ifp, &IA_SIN(ifa)->sin_addr, - &IA_SIN(ifa)->sin_addr, IF_LLADDR(ifp)); + &IA_SIN(ifa)->sin_addr, enaddr); ifa->ifa_rtrequest = arp_rtrequest; ifa->ifa_flags |= RTF_CLONING; } @@ -949,11 +955,13 @@ void arp_ifinit2(struct ifnet *ifp, struct ifaddr *ifa, u_char *enaddr) { - if (ntohl(IA_SIN(ifa)->sin_addr.s_addr) != INADDR_ANY) - arprequest(ifp, &IA_SIN(ifa)->sin_addr, - &IA_SIN(ifa)->sin_addr, enaddr); - ifa->ifa_rtrequest = arp_rtrequest; - ifa->ifa_flags |= RTF_CLONING; + arp_ifinit_internal(ifp, ifa, enaddr); +} + +void +arp_ifinit(struct ifnet *ifp, struct ifaddr *ifa) +{ + arp_ifinit_internal(ifp, ifa, IF_LLADDR(ifp)); } static void ==== //depot/projects/ethng/src/sys/netinet/in_pcb.h#3 (text+ko) - //depot/projects/toestack/sys/netinet/in_pcb.h#3 (text+ko) ==== content @@ -89,6 +89,13 @@ #define ie6_laddr ie_dependladdr.ie6_local }; + +#define SC_ENTRY_PRESENT 1 +#define SC_DROP 2 + +typedef void (*sc_eh_t)(int event, void *arg); + + /* * XXX The defines for inc_* are hacks and should be changed to direct * references. @@ -99,6 +106,8 @@ u_int16_t inc_pad; /* XXX alignment for in_endpoints */ /* protocol dependent part */ struct in_endpoints inc_ie; + sc_eh_t inc_eh; /* syncache event handler - timeout or already present */ + void *inc_ext; /* external TCP connection state */ }; #define inc_isipv6 inc_flags /* temp compatability */ #define inc_fport inc_ie.ie_fport ==== //depot/projects/ethng/src/sys/netinet/ip_icmp.c#4 (text+ko) - //depot/projects/toestack/sys/netinet/ip_icmp.c#7 (text+ko) ==== content @@ -136,6 +136,33 @@ extern struct protosw inetsw[]; +static void +rt_mtu_update(struct sockaddr *icmpsrc, struct icmp *icp) +{ + struct rtentry *rt; + int mtu; + + rt = rtalloc1(icmpsrc, 0, RTF_CLONING); + if (rt && (rt->rt_flags & RTF_HOST)) { + mtu = ntohs(icp->icmp_nextmtu); + if (!mtu) + mtu = ip_next_mtu(rt->rt_rmx.rmx_mtu, + 1); +#ifdef DEBUG_MTUDISC + printf("MTU for %s reduced to %d\n", + inet_ntoa(icmpsrc.sin_addr), mtu); +#endif + if (mtu >= 296 && rt->rt_rmx.rmx_mtu > mtu) { + rt->rt_rmx.rmx_mtu = mtu; + EVENTHANDLER_INVOKE(route_event, RTEVENT_PMTU_UPDATE, rt, NULL); + } + } + if (rt) + RTFREE_LOCKED(rt); +} + + + /* * Generate an error packet of type error * in response to bad packet ip. @@ -442,6 +469,11 @@ #endif icmpsrc.sin_addr = icp->icmp_ip.ip_dst; /* + * Update the route directly for use by protocol offload + */ + if (code == PRC_MSGSIZE) + rt_mtu_update((struct sockaddr *)&icmpsrc, icp); + /* * XXX if the packet contains [IPv4 AH TCP], we can't make a * notification to TCP layer. */ ==== //depot/projects/ethng/src/sys/netinet/ip_options.c#3 (text+ko) - //depot/projects/toestack/sys/netinet/ip_options.c#4 (text+ko) ==== content @@ -404,6 +404,9 @@ struct mbuf *m; struct ipopt_tag *opts; + if (m0 == NULL) + return (NULL); + opts = (struct ipopt_tag *)m_tag_find(m0, PACKET_TAG_IPOPTIONS, NULL); if (opts == NULL) return (NULL); ==== //depot/projects/ethng/src/sys/netinet/tcp.h#1 (text+ko) - //depot/projects/toestack/sys/netinet/tcp.h#2 (text+ko) ==== content @@ -147,6 +147,10 @@ #define TCP_NOOPT 0x08 /* don't use TCP options */ #define TCP_MD5SIG 0x10 /* use MD5 digests (RFC2385) */ #define TCP_INFO 0x20 /* retrieve tcp_info structure */ +#define TCP_CONGESTION 0x40 /* congestion control algorithm */ + +#define TCP_CA_NAME_MAX 16 /* max congestion control name len */ + #define TCPI_OPT_TIMESTAMPS 0x01 #define TCPI_OPT_SACK 0x02 ==== - //depot/projects/toestack/sys/netinet/tcp_ofld.c#5 ==== ==== - //depot/projects/toestack/sys/netinet/tcp_ofld.h#6 ==== ==== //depot/projects/ethng/src/sys/netinet/tcp_subr.c#6 (text+ko) - //depot/projects/toestack/sys/netinet/tcp_subr.c#7 (text+ko) ==== content @@ -85,6 +85,7 @@ #include #include #include +#include #ifdef INET6 #include #endif @@ -651,7 +652,7 @@ if (TCPS_HAVERCVDSYN(tp->t_state)) { tp->t_state = TCPS_CLOSED; - (void) tcp_output(tp); + (void) tcp_gen_abort(tp); tcpstat.tcps_drops++; } else tcpstat.tcps_conndrops++; @@ -768,6 +769,9 @@ INP_INFO_WLOCK_ASSERT(&tcbinfo); INP_LOCK_ASSERT(inp); + if (tp->t_state == TCPS_LISTEN) + tcp_gen_listen_close(tp); + in_pcbdrop(inp); tcpstat.tcps_closed++; KASSERT(inp->inp_socket != NULL, ("tcp_close: inp_socket NULL")); @@ -1562,7 +1566,7 @@ tp->snd_recover = tp->snd_max; if (tp->t_flags & TF_SACK_PERMIT) EXIT_FASTRECOVERY(tp); - tcp_output(tp); + tcp_gen_send(tp); return (inp); } ==== //depot/projects/ethng/src/sys/netinet/tcp_syncache.c#4 (text+ko) - //depot/projects/toestack/sys/netinet/tcp_syncache.c#6 (text+ko) ==== content @@ -353,6 +353,10 @@ TAILQ_REMOVE(&sch->sch_bucket, sc, sc_hash); sch->sch_length--; +#ifndef DISABLE_TCP_OFFLOAD + if (sc->sc_inc.inc_eh && sc->sc_inc.inc_ext) + sc->sc_inc.inc_eh(SC_DROP, sc->sc_inc.inc_ext); +#endif syncache_free(sc); tcp_syncache.cache_count--; } @@ -403,7 +407,10 @@ sch->sch_nextc = sc->sc_rxttime; continue; } - +#ifndef DISABLE_TCP_OFFLOAD + if (sc->sc_inc.inc_eh != NULL) + continue; +#endif if (sc->sc_rxmits > tcp_syncache.rexmt_limit) { if ((s = tcp_log_addrs(&sc->sc_inc, NULL, NULL, NULL))) { log(LOG_DEBUG, "%s; %s: Retransmits exhausted, " @@ -870,7 +877,7 @@ * Segment validation: * ACK must match our initial sequence number + 1 (the SYN|ACK). */ - if (th->th_ack != sc->sc_iss + 1) { + if (th->th_ack != sc->sc_iss + 1 && sc->sc_inc.inc_eh == NULL) { if ((s = tcp_log_addrs(inc, th, NULL, NULL))) log(LOG_DEBUG, "%s; %s: ACK %u != ISS+1 %u, segment " "rejected\n", s, __func__, th->th_ack, sc->sc_iss); @@ -881,7 +888,7 @@ * number + 1 (the SYN) because we didn't ACK any data that * may have come with the SYN. */ - if (th->th_seq != sc->sc_irs + 1) { + if (th->th_seq != sc->sc_irs + 1 && sc->sc_inc.inc_eh == NULL) { if ((s = tcp_log_addrs(inc, th, NULL, NULL))) log(LOG_DEBUG, "%s; %s: SEQ %u != IRS+1 %u, segment " "rejected\n", s, __func__, th->th_seq, sc->sc_irs); @@ -908,7 +915,7 @@ * If timestamps were negotiated the reflected timestamp * must be equal to what we actually sent in the SYN|ACK. */ - if ((to->to_flags & TOF_TS) && to->to_tsecr != sc->sc_ts) { + if ((to->to_flags & TOF_TS) && to->to_tsecr != sc->sc_ts && sc->sc_inc.inc_eh == NULL) { if ((s = tcp_log_addrs(inc, th, NULL, NULL))) log(LOG_DEBUG, "%s; %s: TSECR %u != TS %u, " "segment rejected\n", @@ -1028,6 +1035,10 @@ sc = syncache_lookup(inc, &sch); /* returns locked entry */ SCH_LOCK_ASSERT(sch); if (sc != NULL) { +#ifndef DISABLE_TCP_OFFLOAD + if (sc->sc_inc.inc_eh && sc->sc_inc.inc_ext) + sc->sc_inc.inc_eh(SC_ENTRY_PRESENT, sc->sc_inc.inc_ext); +#endif tcpstat.tcps_sc_dupsyn++; if (ipopts) { /* @@ -1062,7 +1073,7 @@ s, __func__); free(s, M_TCPLOG); } - if (syncache_respond(sc) == 0) { + if ((inc->inc_eh == NULL) && syncache_respond(sc) == 0) { sc->sc_rxmits = 0; syncache_timeout(sc, sch, 1); tcpstat.tcps_sndacks++; @@ -1203,7 +1214,7 @@ /* * Do a standard 3-way handshake. */ - if (syncache_respond(sc) == 0) { + if (inc->inc_ext != NULL || syncache_respond(sc) == 0) { if (tcp_syncookies && tcp_syncookiesonly && sc != &scs) syncache_free(sc); else if (sc != &scs) @@ -1221,8 +1232,11 @@ if (sc == &scs) mac_syncache_destroy(&maclabel); #endif - *lsop = NULL; - m_freem(m); + if (m) { + + *lsop = NULL; + m_freem(m); + } return; } ==== //depot/projects/ethng/src/sys/netinet/tcp_usrreq.c#5 (text+ko) - //depot/projects/toestack/sys/netinet/tcp_usrreq.c#7 (text+ko) ==== content @@ -85,6 +85,7 @@ #ifdef TCPDEBUG #include #endif +#include /* * TCP protocol interface to socket abstraction. @@ -385,6 +386,7 @@ if (error == 0) { tp->t_state = TCPS_LISTEN; solisten_proto(so, backlog); + tcp_gen_listen_open(tp); } SOCK_UNLOCK(so); @@ -476,7 +478,7 @@ TCPDEBUG1(); if ((error = tcp_connect(tp, nam, td)) != 0) goto out; - error = tcp_output(tp); + error = tcp_gen_connect(so, nam); out: TCPDEBUG2(PRU_CONNECT); INP_UNLOCK(inp); @@ -528,7 +530,7 @@ inp->inp_vflag &= ~INP_IPV6; if ((error = tcp_connect(tp, (struct sockaddr *)&sin, td)) != 0) goto out; - error = tcp_output(tp); + error = tcp_gen_connect(so, nam); goto out; } inp->inp_vflag &= ~INP_IPV4; @@ -536,7 +538,7 @@ inp->inp_inc.inc_isipv6 = 1; if ((error = tcp6_connect(tp, nam, td)) != 0) goto out; - error = tcp_output(tp); + error = tcp_gen_connect(so, nam); out: TCPDEBUG2(PRU_CONNECT); @@ -703,7 +705,7 @@ TCPDEBUG1(); socantsendmore(so); tcp_usrclosed(tp); - error = tcp_output(tp); + error = tcp_gen_disconnect(tp); out: TCPDEBUG2(PRU_SHUTDOWN); @@ -733,7 +735,7 @@ } tp = intotcpcb(inp); TCPDEBUG1(); - tcp_output(tp); + tcp_gen_rcvd(tp); out: TCPDEBUG2(PRU_RCVD); @@ -838,7 +840,7 @@ if (tp != NULL) { if (flags & PRUS_MORETOCOME) tp->t_flags |= TF_MORETOCOME; - error = tcp_output(tp); + error = tcp_gen_send(tp); if (flags & PRUS_MORETOCOME) tp->t_flags &= ~TF_MORETOCOME; } @@ -889,7 +891,7 @@ } tp->snd_up = tp->snd_una + so->so_snd.sb_cc; tp->t_flags |= TF_FORCEDATA; - error = tcp_output(tp); + error = tcp_gen_send(tp); tp->t_flags &= ~TF_FORCEDATA; } out: @@ -1489,7 +1491,7 @@ sbflush(&so->so_rcv); tcp_usrclosed(tp); if (!(inp->inp_vflag & INP_DROPPED)) - tcp_output(tp); + tcp_gen_disconnect(tp); } } @@ -1511,8 +1513,9 @@ INP_LOCK_ASSERT(tp->t_inpcb); switch (tp->t_state) { + case TCPS_LISTEN: + tcp_gen_listen_close(tp); case TCPS_CLOSED: - case TCPS_LISTEN: tp->t_state = TCPS_CLOSED; tp = tcp_close(tp); /* ==== //depot/projects/ethng/src/sys/netinet/tcp_var.h#3 (text+ko) - //depot/projects/toestack/sys/netinet/tcp_var.h#6 (text+ko) ==== content @@ -123,6 +123,7 @@ #define TF_SIGNATURE 0x400000 /* require MD5 digests (RFC2385) */ #define TF_FORCEDATA 0x800000 /* force out a byte */ #define TF_TSO 0x1000000 /* TSO enabled on this connection */ +#define TF_TOE 0x2000000 /* TOE enabled on this connection */ tcp_seq snd_una; /* send unacknowledged */ tcp_seq snd_max; /* highest sequence number sent; @@ -206,6 +207,9 @@ int t_rttlow; /* smallest observerved RTT */ u_int32_t rfbuf_ts; /* recv buffer autoscaling timestamp */ int rfbuf_cnt; /* recv buffer autoscaling byte count */ + struct toe_usrreqs *t_tu; /* offload operations vector */ + void *t_toe; + char *t_cong_control; /* congestion control algorithm name*/ }; #define IN_FASTRECOVERY(tp) (tp->t_flags & TF_FASTRECOVERY)