lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] IP forwarding to/from PPP working for one netif, but no


From: address@hidden
Subject: Re: [lwip-users] IP forwarding to/from PPP working for one netif, but not another
Date: Thu, 30 Jan 2020 22:11:23 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2

Am 30.01.2020 um 22:02 schrieb Sylvain Rochet:
Hi Simon,

On Thu, Jan 30, 2020 at 09:31:11PM +0100, address@hidden wrote:
Am 30.01.2020 um 20:42 schrieb Sylvain Rochet:
On Wed, Jan 29, 2020 at 08:15:11PM -0800, Andrew Pullin wrote:

Host2:
     - Micontroller device, ESP32
     - has both WiFi and Ethernet PHY hardware (IP101GRI Ethernet PHY), used
mutually exclusively
     - Running lwIP
     - WiFi and Ethernet are independently verified to work to reach WAN from
this host
     - PPPoS server
     - ppp0 : 10.0.0.1/32
         - IP for server and client are hard-coded in
         - I believe it is /32, as the netmask is reported as 255.255.255.255
     - When running w/ WiFi:
         - wlan0 : ip 10.0.200.136/16  (IP and /16 from DHCP server)
     - When running w/ Ethernet:
         - eth0 : ip 10.0.200.113/16  (IP and /16 from DHCP server)

One odd thing I find here is that lwIP does not support 2 interfaces in
the same subnet. So you would have to take care that only one netif at a
time has its link set up (or its address set or its administrative
status up, or whatever). In any case, having both wlan0 and eth0 up and
running with an address in the same subnet will result in packets being
accepted on both netifs but transmitted on whichever was registered last
(or was it first?).

I assumed that both were not active at the same time, good catch, this
might be an issue as well.


This is not "connection sharing", this is IP routing, not NAT !,
"connection sharing" is usually used for hosts that do SNAT on their
Interface facing Internet.

IP routing needs a complete routing table on all hosts telling how to
reach (i.e. which next-hop to use) every host of the whole network.

Example with 2 subnets and 3 Hosts:

A-eth0  --------------------- eth0-B-eth1 --------------------- eth0-C
    192.168.0.1/24    192.168.0.2/24   172.16.1.1/24     172.16.1.2/24

Host A routing table:
192.168.0.0/24 dev eth0
172.16.1.0/24 via 192.168.0.2

Host B routing table:
192.168.0.0/24 dev eth0
172.16.1.0/24 dev eth1

Host C routing table:
192.168.0.0/24 via 172.16.1.1
172.16.1.0/24 dev eth0

dev = directly connected
via = next-hop, gateway if you prefer

What you could see is that each host have a similar routing table, just
the next-hop changes. Default route is just a way to reduce the routing
table size by removing all entries that have an identical next-hop.

Which brings me to a question: how do we define such routing rules in
lwIP? Hmm...

I'm surprised by the question :-) In lwIP, "dev" rules don't need to be
added, the ip4_route function "create" them dynamically using the
interface address/netmask.

Well, yes, my bad. The question wasn't phrased well. The thing I don't
understand (because I'm not using it) probably all boils down to using
lwIP as a PPP 'proxy' to remote networks without doing NAT at the same
time (which we don't support in mainline). That's not standard routing...


But thanks you for asking that because there is a huuuuuge issue about
that with the aforementioned case. Since "dev" rules are not ordered
because we just foreach on interfaces list until a match, we don't
respect that smaller subnets should be checked and matched first. So if
an IP subnet is within the IP subnet of another interface, although
perfectly legal configuration but *bad* design, it does not work in
lwIP. In lwIP it actually depends on the order interfaces were added :-)

Which results in me citing my mantra "lwIP does *not* support multiple
netifs in the same subnet". (And for those who ask why: most of the
time, this is just bad network desing. For the rest where it is
intended: we could make it work, but the burdon on the rest of us not
needing it has been too much, up to now.)


For "via" routes, we have LWIP_HOOK_IP4_ROUTE.

Yeah, well, this is probably not used much, being a hook that people
need to implement on their own? A default implementation for a routing
algorithm woule be nice...

Regards,
Simon



reply via email to

[Prev in Thread] Current Thread [Next in Thread]