[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE : RE : [lwip-users] "the ARP layer is notprotectedagainstconcurrentac
From: |
Frédéric BERNON |
Subject: |
RE : RE : [lwip-users] "the ARP layer is notprotectedagainstconcurrentaccess" |
Date: |
Mon, 5 Mar 2007 12:02:13 +0100 |
Ok Simon, just see there what I think to propose. Like for the arp_timer
initialize, I think it MUST be done like this. I don't think it's change
something for RAW API users, except they have to set TCPIP_PACKET_INPUT to 0
(and in fact, because it's driver dependant, it's only change the ethernetif
skeleton). Kieran, Simon (and others), what's your opinon?
In opt.h
#ifndef TCPIP_PACKET_INPUT
#define TCPIP_PACKET_INPUT 1
#endif
In ethernetif.c :
static void
ethernetif_input(struct netif *netif)
{
struct ethernetif *ethernetif;
struct eth_hdr *ethhdr;
struct pbuf *p;
ethernetif = netif->state;
/* move received packet into a new pbuf */
p = low_level_input(netif);
/* no packet could be read, silently ignore this */
if (p == NULL) return;
/* points to packet payload, which starts with an Ethernet header */
ethhdr = p->payload;
#if LINK_STATS
lwip_stats.link.recv++;
#endif /* LINK_STATS */
switch (htons(ethhdr->type)) {
#if TCPIP_PACKET_INPUT
/* ARP or IP packet? */
case ETHTYPE_IP:
case ETHTYPE_ARP:
/* full packet send to tcpip_thread */
netif->input(p, netif);
break;
#else
/* IP packet? */
case ETHTYPE_IP:
#if ETHARP_TRUST_IP_MAC
/* update ARP table */
etharp_ip_input( netif, p);
#endif
/* skip Ethernet header */
pbuf_header(p, -sizeof(struct eth_hdr));
/* pass to network layer */
netif->input(p, netif);
break;
case ETHTYPE_ARP:
/* pass p to ARP module */
etharp_arp_input(netif, ethernetif->ethaddr, p);
break;
#endif
default:
pbuf_free(p);
p = NULL;
break;
}
}
And in tcpip.c:
#if TCPIP_PACKET_INPUT
err_t packet_input(struct pbuf *p, struct netif *inp)
{
struct ethernetif *ethernetif;
struct eth_hdr *ethhdr;
struct pbuf *p;
ethernetif = netif->state;
/* points to packet payload, which starts with an Ethernet header */
ethhdr = p->payload;
#if LINK_STATS
lwip_stats.link.recv++;
#endif /* LINK_STATS */
switch (htons(ethhdr->type)) {
/* IP packet? */
case ETHTYPE_IP:
#if ETHARP_TRUST_IP_MAC
/* update ARP table */
etharp_ip_input( netif, p);
#endif
/* skip Ethernet header */
pbuf_header(p, -sizeof(struct eth_hdr));
/* pass to IP layer */
ip_input(p, netif);
break;
case ETHTYPE_ARP:
/* pass p to ARP module */
etharp_arp_input(netif, ethernetif->ethaddr, p);
break;
default: /* Not really necessary, but...*/
pbuf_free(p);
p = NULL;
break;
}
}
#endif /* TCPIP_PACKET_INPUT */
static void
tcpip_thread(void *arg)
{
struct tcpip_msg *msg;
#if IP_REASSEMBLY
sys_timeout( 1000, ip_timer, NULL);
#endif
if (tcpip_init_done != NULL) {
tcpip_init_done(tcpip_init_done_arg);
}
while (1) { /* MAIN Loop */
sys_mbox_fetch(mbox, (void *)&msg, 0);
switch (msg->type) {
case TCPIP_MSG_API:
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: API message %p\n", (void *)msg));
api_msg_input(msg->msg.apimsg);
break;
case TCPIP_MSG_INPUT:
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: IP packet %p\n", (void *)msg));
#if TCPIP_PACKET_INPUT
packet_input(msg->msg.inp.p, msg->msg.inp.netif);
#else
ip_input(msg->msg.inp.p, msg->msg.inp.netif);
#endif
break;
case TCPIP_MSG_CALLBACK:
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK %p\n", (void *)msg));
msg->msg.cb.f(msg->msg.cb.ctx);
break;
default:
break;
}
memp_free(MEMP_TCPIP_MSG, msg);
}
}
====================================
Frédéric BERNON
HYMATOM SA
Chef de projet informatique
Microsoft Certified Professional
Tél. : +33 (0)4-67-87-61-10
Fax. : +33 (0)4-67-70-85-44
Email : address@hidden
Web Site : http://www.hymatom.fr
====================================
P Avant d'imprimer, penser à l'environnement
-----Message d'origine-----
De : address@hidden [mailto:address@hidden De la part de Goldschmidt Simon
Envoyé : lundi 5 mars 2007 11:43
À : Mailing list for lwIP users
Objet : RE: RE : [lwip-users] "the ARP layer is
notprotectedagainstconcurrentaccess"
Hi Frédéric,
> >The solution which Frédéric proposed is simpler, but sends
> ALL packets to the tcpip_thread. Filtering them before
> passing on seemed more performant to me.
>
> Yes, I've got the same idea yesterday :) Even if on a
> "classic" network, most of packets are IP & ARP, there is
> some others packets for STP or other Ethernet level protocols
> (in my network, there is something like 120 devices, and, in
> 5 sec, there is something like 15 "low-level" packets).
>
> This is always the same problem : more code in "receive"
> thread (so footprint increase), to save processor time. I
> don't think this this a problem, and I can propose a "clean"
> patch if Simon is ok with this solution...
Of course I would like to see your patch, although I already have one myself
(since I'm using the stack this way, already). I think it's always better to
see another idea, so if you have a patch, please submit it, I'll file a bug
entry.
Simon
_______________________________________________
lwip-users mailing list
address@hidden http://lists.nongnu.org/mailman/listinfo/lwip-users
Frédéric BERNON.vcf
Description: Frédéric BERNON.vcf
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- RE : RE : [lwip-users] "the ARP layer is notprotectedagainstconcurrentaccess",
Frédéric BERNON <=