[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] byte order, packing, optimizations
From: |
Stéphane Lesage |
Subject: |
[lwip-devel] byte order, packing, optimizations |
Date: |
Mon, 08 Feb 2010 12:10:41 +0100 |
User-agent: |
Thunderbird 2.0.0.23 (Windows/20090812) |
This is a follow-up from http://savannah.nongnu.org/bugs/?27352
>Oh, and when the structs are packed, I don't think we can copy
>u16_t because the port may be free to use unaligned pbuf
>payloads when setting MEM_ALIGN to 1!
Any port which cannot do misaligned access will set MEM_ALIGN to 2 or 4.
Even x86 needs MEM_ALIGN=4 for better performance.
SMEMCPY(&hdr->sipaddr, ipsrc_addr, sizeof(ip_addr_t));
why take the risk of several calls to memcpy inside a function that is
called for every packet ?
hdr->sipaddr is ip_addr2, why not copy 2 u16_t directly or use a
well-defined macro ?
>>BTW, ip_addr_set should be use only for safe copy, the latest
>> modifications use it everywhere, even if we don't have to check
>> the pointer.
>I might have to check that again, but I think the only places where I
used that unchecked is the SNMP code.
>If there are other places where it is used unchecked, please tell me.
In most of the following places, the pointer is a field of a structure,
so it will never be null:
core\dhcp.c(249): ip_addr_set(&dhcp->offered_ip_addr,
&dhcp->msg_in->yiaddr);
core\dhcp.c(536): ip_addr_set(&dhcp->offered_ip_addr,
&dhcp->msg_in->yiaddr);
core\dhcp.c(541): ip_addr_set(&dhcp->offered_si_addr,
&dhcp->msg_in->siaddr);
core\dhcp.c(928): ip_addr_set(&sn_mask, &dhcp->offered_sn_mask);
core\dhcp.c(941): ip_addr_set(&gw_addr, &dhcp->offered_gw_addr);
core\dhcp.c(1650): ip_addr_set(&dhcp->msg_out->ciaddr, &netif->ip_addr);
core\tcp.c(235): ip_addr_set(&local_ip, &(pcb->local_ip));
core\tcp.c(236): ip_addr_set(&remote_ip, &(pcb->remote_ip));
core\tcp.c(390): ip_addr_set(&lpcb->local_ip, &pcb->local_ip);
core\tcp_in.c(436): ip_addr_set(&(npcb->local_ip), &(iphdr->dest));
core\tcp_in.c(438): ip_addr_set(&(npcb->remote_ip), &(iphdr->src));
core\tcp_out.c(706): ip_addr_set(&(pcb->local_ip), &(netif->ip_addr));
core\ipv4\icmp.c(187): ip_addr_set(&tmpaddr, &iphdr->src);
core\ipv4\icmp.c(188): ip_addr_set(&iphdr->src, &iphdr->dest);
core\ipv4\icmp.c(189): ip_addr_set(&iphdr->dest, &tmpaddr);
core\ipv4\igmp.c(285): ip_addr_set(&(group->group_address), addr);
core\ipv4\igmp.c(735): ip_addr_set(&src, &((group->netif)->ip_addr));
core\ipv4\igmp.c(739): ip_addr_set(&(igmp->igmp_group_address),
&(group->group_address));
core\ipv4\igmp.c(744): ip_addr_set(&(igmp->igmp_group_address),
&(group->group_address));
core\ipv4\ip.c(569): ip_addr_set(&(iphdr->src), &(netif->ip_addr));
core\ipv6\icmp6.c(79): ip_addr_set(&tmpaddr, &(iphdr->src));
core\ipv6\icmp6.c(80): ip_addr_set(&(iphdr->src), &(iphdr->dest));
core\ipv6\icmp6.c(81): ip_addr_set(&(iphdr->dest), &tmpaddr);
core\ipv6\ip6.c(290): ip_addr_set(&(iphdr->src), &(netif->ip_addr));
core\snmp\msg_out.c(233): ip_addr_set(&trap_msg.dip, &td->dip);
core\snmp\msg_out.c(236): ip_addr_set(&dst_ip, &dst_if->ip_addr);
should be changed to:
#define ip_addr_set_any(ipaddr) (ipaddr)->addr = IPADDR_ANY
core\dhcp.c(837): ip_addr_set(&dhcp->offered_ip_addr, IP_ADDR_ANY);
core\udp.c(742): ip_addr_set(&pcb->remote_ip, IP_ADDR_ANY);
core\snmp\mib2.c(1445): ip_addr_set(&dst, &ip_addr_any);
core\snmp\mib2.c(1522): ip_addr_set(&dst, &ip_addr_any);
- [lwip-devel] byte order, packing, optimizations,
Stéphane Lesage <=
- Re: [lwip-devel] byte order, packing, optimizations, Simon Goldschmidt, 2010/02/08
- Re: [lwip-devel] byte order, packing, optimizations, Stéphane Lesage, 2010/02/08
- RE: [lwip-devel] byte order, packing, optimizations, Stéphane Lesage, 2010/02/13
- RE: [lwip-devel] byte order, packing, optimizations, Stéphane Lesage, 2010/02/13
- Re: [lwip-devel] byte order, packing, optimizations, address@hidden, 2010/02/13
- Re: [lwip-devel] byte order, packing, optimizations, Kieran Mansley, 2010/02/15
- RE: [lwip-devel] byte order, packing, optimizations, Bill Auerbach, 2010/02/15
- RE: [lwip-devel] byte order, packing, optimizations, Simon Goldschmidt, 2010/02/15