About ether_output() function in if_etheresubr.c

Albert Huang alberthuang314 at gmail.com
Tue Mar 17 14:24:46 UTC 2015


Hi, Daniel,

Thanks for your reply. After digging more into it, PC does not receive
ARP reply from RTEMS. That's the problem of device driver for sure, and
I'll try to debug it tomorrow when I go to work.

But my question is the two ether_output() in a row. It looks like that
the ICMP packet was sent from IP layer to Ethernet layer by calling
ether_output(), but the other packet causes calling to ether_output()
again before previous packet getting processed by the remaining code of
ether_output(). Is this normal? Is there any synchronization problem
here? We developed our own BSP as well, so everything might be
wrong. :-)

Sometimes I get ether_output() with 84 bytes, and then ether_output()
with 0 bytes. That's very suspicious.

Best regards,

Albert


Daniel Hellstrom <daniel at gaisler.com> writes:

> Hello Albert,
>
> Please provide more information about the order and content of the
> packets being transferred.
>
> My guess is that the following would happen:
>  1. PC sends to broadcast: ARP request for RTEMS IP
>  2. RTEMS responds PC: ARP reply
>  3. PC sends to RTEMS: PING request
>  4. RTEMS sends to broadcast: ARP request for PING reply IP
>  5. PC responds RTEMS: ARP reply
>  6. RTEMS sends to PC: PING reply
>
> Thus three Ethernet frames from the RTEMS machine.
>
> You can use wireshark to sniff the traffic and present it in detail. I
> think you need wireshark or similar if you are going to develop a
> network driver for RTEMS.
>
> Regards,
> Daniel H
>
>  On 03/17/2015 07:13 AM, Albert Chun-Chieh Huang wrote:
>> Hi, all,
>>
>> I'm currently working on adding a network device driver to
>> rtems. The source tree was grabbed on July, 2014. It's still not
>> working properly right now. But I have some questions about the
>> network stack code.
>>
>> I added printf function in if_etheresubr.c in the directory cpukit/libnetworking/net/ as the following:
>> int
>> ether_output(struct ifnet *ifp, struct mbuf *m,
>>     struct sockaddr *dst, struct rtentry *rt0)
>> {
>>     short type;
>>     int s, error = 0;
>>     u_char  edst[6];
>>     register struct rtentry *rt;
>>     struct mbuf *mcopy = (struct mbuf *)0;
>>     register struct ether_header *eh;
>>     int len = m->m_pkthdr.len;
>>     struct arpcom *ac = (struct arpcom *)ifp;
>> #ifdef NETATALK
>>     struct at_ifaddr *aa;
>> #endif /* NETATALK */
>>
>>     if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
>>         senderr(ENETDOWN);
>>     printk("ether_output: length = %d, if_flags = 0x%08x\n", len, ifp->if_flags);
>> ========================================
>>
>> And I got the following messages when I ping the RTEMS system on ARM:
>> =======================================================
>> ip_output 0, length = 84, MTU = 1500
>> ether_output: length = 84, if_flags = 0x00000847
>> ether_output: length = 28, if_flags = 0x00000847
>> if_ethersubr.c: m_len = 28, leading space = 68
>> if_ethersubr.c: MSIZE = 128, MLEN = 104
>> if_ethersubr.c: m_len = 42
>> =======================================================
>>
>> During this period of time, there are only two kinds of packets, one
>> is PING(echo reply), the other is ARP; the one with 84 bytes is
>> PING, and the one with 28 is ARP, both will be added 14 bytes of
>> Ethernet header later, and makes them 98 bytes and 42 bytes.
>>
>> Here, ether_output() was called twice when a PING is sent from IP
>> layer. Is it normal? I didn't get PING reply from this board. And I
>> just want to make sure if ether_output being called twice normal or
>> not, so that I can decide which way to go.
>>
>> Thanks in advance.
>>
>>
>> Albert
>>
>>
>> _______________________________________________
>> devel mailing list
>> devel at rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel



More information about the devel mailing list