fixed bug #36403 "ip4_input() and ip6_input() always pass inp to higher layers": now the accepting netif is passed up, but the input netif is available through ip_current_input_netif() if required.

This commit is contained in:
sg 2015-02-12 22:04:10 +01:00
parent 81d4e201bb
commit 80b62df0a9
4 changed files with 18 additions and 3 deletions

View File

@ -167,6 +167,10 @@ HISTORY
++ Bugfixes:
* ip.h, ip4.c, ip6.c: fixed bug #36403 "ip4_input() and ip6_input() always pass
inp to higher layers": now the accepting netif is passed up, but the input
netif is available through ip_current_input_netif() if required.
2015-02-11: patch by hichard
* tcpip.c: fixed bug #43094 "The function tcpip_input() forget to handle IPv6"

View File

@ -553,7 +553,8 @@ ip_input(struct pbuf *p, struct netif *inp)
ip_debug_print(p);
LWIP_DEBUGF(IP_DEBUG, ("ip_input: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len));
ip_data.current_netif = inp;
ip_data.current_netif = netif;
ip_data.current_input_netif = inp;
ip_data.current_ip4_header = iphdr;
ip_data.current_ip_header_tot_len = IPH_HL(iphdr) * 4;
@ -613,6 +614,7 @@ ip_input(struct pbuf *p, struct netif *inp)
/* @todo: this is not really necessary... */
ip_data.current_netif = NULL;
ip_data.current_input_netif = NULL;
ip_data.current_ip4_header = NULL;
ip_data.current_ip_header_tot_len = 0;
ip_addr_set_any(ip_current_src_addr());

View File

@ -397,6 +397,7 @@ ip6_input(struct pbuf *p, struct netif *inp)
/* In netif, used in case we need to send ICMPv6 packets back. */
ip_data.current_netif = inp;
ip_data.current_input_netif = inp;
/* match packet against an interface, i.e. is this packet for us? */
if (ip6_addr_ismulticast(ip6_current_dest_addr())) {
@ -708,6 +709,7 @@ options_done:
ip6_input_cleanup:
ip_data.current_netif = NULL;
ip_data.current_input_netif = NULL;
ip_data.current_ip6_header = NULL;
ip_data.current_ip_header_tot_len = 0;
ip6_addr_set_any(&ip_data.current_iphdr_src.ip6);

View File

@ -116,8 +116,10 @@ struct ip_pcb {
/* Global variables of this module, kept in a struct for efficient access using base+index. */
struct ip_globals
{
/** The interface that provided the packet for the current callback invocation. */
/** The interface that accepted the packet for the current callback invocation. */
struct netif *current_netif;
/** The interface that received the packet for the current callback invocation. */
struct netif *current_input_netif;
/** Header of the input packet currently being processed. */
const struct ip_hdr *current_ip4_header;
#if LWIP_IPV6
@ -134,10 +136,15 @@ struct ip_globals
extern struct ip_globals ip_data;
/** Get the interface that received the current packet.
/** Get the interface that accepted the current packet.
* This may or may not be the receiving netif, depending on your netif/network setup.
* This function must only be called from a receive callback (udp_recv,
* raw_recv, tcp_accept). It will return NULL otherwise. */
#define ip_current_netif() (ip_data.current_netif)
/** Get the interface that received the current packet.
* This function must only be called from a receive callback (udp_recv,
* raw_recv, tcp_accept). It will return NULL otherwise. */
#define ip_current_input_netif() (ip_data.current_input_netif)
/** Get the IP header of the current packet.
* This function must only be called from a receive callback (udp_recv,
* raw_recv, tcp_accept). It will return NULL otherwise. */