Re: [lwip-users] Sending to a non-local network without default netif set

2014-11-19 Thread Fabian Koch
Hey Joel,

well yes. I was talking about the scenario you describe in 1).
Although my experience with the windows stack in this world has always been: 
the last connected interface wins and is used for default gateway which 
always sucked when my 100Mbit cable was detected first and the wireless 
connection last (when transferring big files).
The solution was to unplug/replug the Ethernet cable.

But yeah. The other scenario in my opinion is simply a misconfiguration and can 
never work in real life so we shouldn't strive to support that at all.

I don't see LwIP in a routing/switching context, so VLAN is also a topic that I 
would not expect to be covered by us. Normal clients don't need to be aware of 
VLAN tagging as this is usually done between switches.

IP forwarding and real routing is also out of scope for LwIP imho.

But still. We do support multiple netifs, so we should make an effort to 
support configurations that come to mind easily, like two or more netifs on the 
same subnet.

Trunking or bonding or link bundling (e.g. LACP) is also out of scope for 
LwIP imho.

Hope you guys agree.

Cheers,
Fabian

From: lwip-users-bounces+fabian.koch=de.abb@nongnu.org 
[mailto:lwip-users-bounces+fabian.koch=de.abb@nongnu.org] On Behalf Of Joel 
Cunningham
Sent: Dienstag, 18. November 2014 15:51
To: Mailing list for lwIP users
Cc: Mailing list for lwIP users
Subject: Re: [lwip-users] Sending to a non-local network without default netif 
set

we do have a setup with two netifs and we cannot determine what the customer 
will do with the device so we need to also check for same subnet scenarios.

I would like to make a clear distinction between two possible same subnet 
scenarios

1) A multi-homed product is connected to the same logical network via two (or 
more) different links.  One example is a laptop connected to the same LAN via a 
wired Ethernet connection and a wireless connection.  This is a valid 
configuration and both links will have the same subnet of the LAN. Stacks like 
Windows support this and assign an interface metric to the out going 
interfaces.  The metric is used in picking an outgoing interface.

2) A multi-homed product is connected to two (or more) separate physical 
networks that have the same subnet.  The important differences is that the 
links are to different separate physical networks.  Since the subnets are the 
same, different networks can no longer be identified at the IP address 
abstraction level.  This can be considered an invalid network configuration 
since different IP networks are identified by their subnet/address range.

I'm all in favor of supporting 1) in LwIP as long as the implementation meets 
the light-weight requirements, but I'm not a fan of supporting 2).  This case 
is a huge pain because it permits invalid network configurations.  Not to 
mention, from the application layer you have to introduce some other identifier 
for addressing the different networks (can't use subnet). You end up having to 
forcing sockets onto the appropriate network with SO_BINDTODEVICE.  If we want 
LwIP to detect a case like 2) that would be fine, but then how to do you tell 
the difference between 1  2?

Joel


On Nov 17, 2014, at 06:34 AM, Fabian Koch 
fabian.k...@de.abb.commailto:fabian.k...@de.abb.com wrote:
Hey Simon, Hey Erik,

we do have a setup with two netifs and we cannot determine what the customer 
will do with the device so we need to also check for same subnet scenarios.

I already wrote and email to this (or devel?) list about that a while ago.

We also attacked the problem by including the src IP into the ip_route() 
function and I can provide a patch, but it just doesn't feel right.

The reason this is needed is actually because LwIP uses ip_route() to find a 
netif when the local address is INADDR_ANY.

In udp_connect(), udp_sendto(), tcp_eff_send_mss(), snmp_send_trap() and 
etharp_add_static_entry().

In all those cases, ip_route() is actually not really a good function to find a 
matching netif. If we were to replace those instances with another function 
that is a bit more complicated and finds a fitting netif with more aspects 
including gateway settings and network reachability (if that's even a word...) 
then it would make the final routing a bit easier.

Also, the default_netif construct is just too simple to make all this work 
correctly.

If you need a quick solution, you can make ip_route include the src, but then 
you also have to add that parameter to tcp_eff_send_mss().

Our middle part of ip_route() looks like this at the moment:

  /* iterate through netifs */
  for (netif = netif_list; netif != NULL ; netif = netif- next ) {
if ( netif_is_up (netif)  netif_is_link_up (netif)) {   //only 
consider interfaces which are up and have a link
  if ( ip_addr_isany (src)) {//when the source IP is INADDR_ANY, the 
socket is not bound to an interface = find the first match (netmask or is 
broadcast)
 if ( ip_addr_netcmp

Re: [lwip-users] Sending to a non-local network without default netif set

2014-11-18 Thread Joel Cunningham
-local network without default netif 
set

 


HaaCee2 wrote:

I beg to differ 



I've added a task for this to the tracker:

https://savannah.nongnu.org/task/index.php?13397


Simon
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users ___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] Sending to a non-local network without default netif set

2014-11-18 Thread HaaCee2
Isn't 1 Link-layer multiplexing instead of multihoming? The rfc1122 
mentions this explicitly as NOT being multi-homing:

quote

  Finally, we note another possibility that is NOT
 multihoming:  one logical interface may be bound to multiple
 physical interfaces, in order to increase the reliability or
 throughput between directly connected machines by providing
 alternative physical paths between them.  For instance, two
 systems might be connected by multiple point-to-point links.
 We call this link-layer multiplexing.

/quote

Besides that there is another configuration that is valid multi-homing:
3) a product is connected to 2 or more separate LOGICAL networks (i.e. 
vlans). Since the logical networks are separate there can be no 
assumption as to the address/subnets that may occur on any of the VLANs. 
Since frames 'belonging' to one VLAN MUST be restricted to that VLAN 
which is identified by the interface (source address).
This is not nescessarily a same subnet scenario but more an 
'indistinguishable subnet' scenario.





--
View this message in context: 
http://lwip.100.n7.nabble.com/Sending-to-a-non-local-network-without-default-netif-set-tp22981p23541.html
Sent from the lwip-users mailing list archive at Nabble.com.___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] Sending to a non-local network without default netif set

2014-11-17 Thread Fabian Koch
Hey Simon, Hey Erik,

we do have a setup with two netifs and we cannot determine what the customer 
will do with the device so we need to also check for same subnet scenarios.

I already wrote and email to this (or devel?) list about that a while ago.

We also attacked the problem by including the src IP into the ip_route() 
function and I can provide a patch, but it just doesn't feel right.

The reason this is needed is actually because LwIP uses ip_route() to find a 
netif when the local address is INADDR_ANY.

In udp_connect(), udp_sendto(), tcp_eff_send_mss(), snmp_send_trap() and 
etharp_add_static_entry().

In all those cases, ip_route() is actually not really a good function to find a 
matching netif. If we were to replace those instances with another function 
that is a bit more complicated and finds a fitting netif with more aspects 
including gateway settings and network reachability (if that's even a word...) 
then it would make the final routing a bit easier.

Also, the default_netif construct is just too simple to make all this work 
correctly.

If you need a quick solution, you can make ip_route include the src, but then 
you also have to add that parameter to tcp_eff_send_mss().

Our middle part of ip_route() looks like this at the moment:

  /* iterate through netifs */
  for (netif = netif_list; netif != NULL; netif = netif-next) {
if (netif_is_up(netif)  netif_is_link_up(netif)) {   //only 
consider interfaces which are up and have a link
  if(ip_addr_isany(src)) {//when the source IP is INADDR_ANY, the 
socket is not bound to an interface = find the first match (netmask or is 
broadcast)
if (ip_addr_netcmp(dest, (netif-ip_addr), (netif-netmask)) || 
ip_addr_cmp(IP_ADDR_BROADCAST, dest)) {
  /* return netif on which to forward IP packet (first matching netif 
when socket is not bound) */
  return netif;
}
  } else { // socket is bound to a specific IP so only match the right 
netif (matching IPs and either fits netmask or is broadcast)
if(ip_addr_cmp((netif-ip_addr), src)  (ip_addr_netcmp(dest, 
(netif-ip_addr), (netif-netmask)) || ip_addr_cmp(IP_ADDR_BROADCAST, dest))) 
{
  /* this socket is bound to a specific interface, so look for that */
  return netif;
}
  }
}
  }

This essentially makes sending on specific interfaces possible when they are 
bound to the IP. Unbound sockets just send on the best matching netif they can 
find.

For this to work, you also need to netif_set_link_up(loop_netif) in netif.c if 
you're using a loopback netif. (I wonder if it can be considered a bug that the 
loopif never gets a link up...)

I would still not like this in the main lwIP source tree, since it just doesn't 
feel right to include the src IP here.


Cheers,
Fabian

From: lwip-users-bounces+fabian.koch=de.abb@nongnu.org 
[mailto:lwip-users-bounces+fabian.koch=de.abb@nongnu.org] On Behalf Of 
goldsi...@gmx.de
Sent: Freitag, 14. November 2014 21:29
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Sending to a non-local network without default netif 
set

HaaCee2 wrote:
I beg to differ

I've added a task for this to the tracker:

https://savannah.nongnu.org/task/index.php?13397


Simon
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] Sending to a non-local network without default netif set

2014-11-14 Thread HaaCee2
In response to the remark:
Simon is right: routing doesn't have anything to do with the source address
and it shouldn't have to

I think Simon is not right (no pun intended).
I am not entirely familiar with the ideas behind LwIP. But sourcebased
routing is very much in line with rfc1122 (ip for hosts). I quote:

 Under the Strong ES model, the route computation for an outgoing datagram
 is the mapping:
 
  route(src IP addr, dest IP addr, TOS) - gateway
 
 Here the source address is included as a parameter in order to select a
 gateway that is directly reachable on the corresponding physical
 interface. Note that this model logically requires that in general there
 be at least one default gateway, and preferably multiple defaults, for
 each IP source address.

We are facing a similar challenge with our project and we need a similar
mechanism. Is the adaptation of the ip_route available somewhere in the
community?

Regards,

Erik van Veelen




--
View this message in context: 
http://lwip.100.n7.nabble.com/Sending-to-a-non-local-network-without-default-netif-set-tp22981p23521.html
Sent from the lwip-users mailing list archive at Nabble.com.

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


Re: [lwip-users] Sending to a non-local network without default netif set

2014-11-14 Thread goldsi...@gmx.de

HaaCee2 wrote:

I am not entirely familiar with the ideas behind LwIP. But sourcebased
routing is very much in line with rfc1122 (ip for hosts). I quote:


Under the Strong ES model, the route computation for an outgoing datagram
is the mapping:

  route(src IP addr, dest IP addr, TOS) - gateway

Here the source address is included as a parameter in order to select a
gateway that is directly reachable on the corresponding physical
interface. Note that this model logically requires that in general there
be at least one default gateway, and preferably multiple defaults, for
each IP source address.


Well, that excerpt is one of 2 possibilities in the RFC. The other 
possibility is to do like lwIP does. I admit though that it looks kind 
of strange sending packets with IP address A to the interface B just 
because you have a matching destination gateway on that netif...


By now, I'm tempted to add source-based routing as an option, although I 
expect people using lwIP wih more than one interface being only a small 
percentage...



Simon

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


Re: [lwip-users] Sending to a non-local network without default netif set

2014-11-14 Thread HaaCee2

On 14-11-14 20:27, Simon Goldschmidt [via lwIP] wrote:
 HaaCee2 wrote:

  I am not entirely familiar with the ideas behind LwIP. But sourcebased
  routing is very much in line with rfc1122 (ip for hosts). I quote:
 
  Under the Strong ES model, the route computation for an outgoing 
 datagram
  is the mapping:
 
route(src IP addr, dest IP addr, TOS) - 
 gateway
 
  Here the source address is included as a parameter in order to 
 select a
  gateway that is directly reachable on the corresponding physical
  interface. Note that this model logically requires that in general 
 there
  be at least one default gateway, and preferably multiple defaults, for
  each IP source address.

 Well, that excerpt is one of 2 possibilities in the RFC. The other
 possibility is to do like lwIP does. I admit though that it looks kind
 of strange sending packets with IP address A to the interface B just
 because you have a matching destination gateway on that netif...
You are correct that it is only 1 of the 2 possibilities, and as 
indicated I am not familiar with the design of lwIP. So it's a perfectly 
valid choice NOT to support sourcebased routing.

 By now, I'm tempted to add source-based routing as an option, although I
 expect people using lwIP wih more than one interface being only a small
 percentage...
I beg to differ
In my opinion the best approach to deal with vlans is to have multiple 
interfaces and then I think one is required to do sourcebased routing. 
Otherwise datagrams destined for a host on one vlan can be visible on 
another vlan (which is obviously undesirable).
Multiple stacks is a possibility here as well, but in embedded designs 
hardly an option

Erik


 Simon

 ___
 lwip-users mailing list
 [hidden email] /user/SendEmail.jtp?type=nodenode=23524i=0
 https://lists.nongnu.org/mailman/listinfo/lwip-users


 
 If you reply to this email, your message will be added to the 
 discussion below:
 http://lwip.100.n7.nabble.com/Sending-to-a-non-local-network-without-default-netif-set-tp22981p23524.html
  

 To unsubscribe from Sending to a non-local network without default 
 netif set, click here 
 http://lwip.100.n7.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=22981code=ZXZ2ZWVsZW5AYWltdmFsbGV5Lm5sfDIyOTgxfC01NzI0OTAwNzY=.
 NAML 
 http://lwip.100.n7.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
  


-- 
Erik van Veelen
AimValley B.V.
Utrechtseweg 38, 1213 TV Hilversum, The Netherlands
Tel: +31 35 689 1929, Fax: +31 35 689 1901
AimValley certificate 
http://www.aimvalley.com/aimvalley-ca-certificate-2007.crt




--
View this message in context: 
http://lwip.100.n7.nabble.com/Sending-to-a-non-local-network-without-default-netif-set-tp22981p23525.html
Sent from the lwip-users mailing list archive at Nabble.com.___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] Sending to a non-local network without default netif set

2014-11-14 Thread goldsi...@gmx.de

HaaCee2 wrote:

I beg to differ


I've added a task for this to the tracker:

https://savannah.nongnu.org/task/index.php?13397


Simon
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Re: [lwip-users] Sending to a non-local network without default netif set

2014-08-08 Thread Fabian Koch
Hey Mark, Simon,

well it does work when introducing the source address in the routing algorithm 
and thats what I did for now.
But obviously, Simon is right: routing doesn't have anything to do with the 
source address and it shouldn't have to.

The underlying problem in LwIP at the moment is that the ip_route() function is 
used to determine the netif that we should be sending on when it's not already 
clear and that leads to most of the problems, because in that early state of 
determining

There are several functions where LwIP uses the output of ip_route() to find a 
local interface to send on. And in those cases, it actually _should_ consider 
the source address (meaning the bind() address). When actually _sending_ the 
packet, the ip_route() should work as usual like any routing algorithm does. 
Only based on destination.

Ip_route() is used in a few places other than the IP layer to determine the 
local netif to send on:
in udp_connect()
in udp_sendto()
in tcp_eff_send_mss()
in snmp_send_trap()
in etharp_add_static_entry()

Essentially, those placed need to get a different function which considers more 
info than ip_route().
Then you also do not need to touch both the ipv6 and the ipv4 version of the 
route function.

But yeah, if you need a quick solution that doesn't quite feel right, using 
the source address in ip_route() is a way to go for now ;o)

Cheers,
Fabian

PS: I also wrote an open issue about this on my experimental fork of lwip on 
github:
https://github.com/tabascoeye/lwip/issues/5
(pull-requests are welcomed)

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


[lwip-users] Sending to a non-local network without default netif set

2014-08-07 Thread Mark Lvov
Hello,

I have two network interfaces: ethernet and ppp (they obviously don't
share a subnet). I need to open a number of TCP connections with the
requirement, that certain connections must be opened via a particular
interface. I was trying to achieve that by binding to an address-port
prior to connecting, where the address corresponds to an address of a
particular interface.

However, I've noticed that when the destination is not in the same
network with any of the interfaces, the packets fail to route, even
though the default gateway on the interface is defined (so there
should be no problem routing the packet).

While reading the source of ip4.c I've realized, that
* the source address is not considered, which means, that binding to a
particular address before connecting is apparently meaningless
* the gw, that's set on the interface is not considered
I understand, that gw *is* considered in etharp_output, but since it
is called after ip_route, it is never reached. etharp_output is not
relevant for ppp, too.

I see, there's the notion of a default interface, but I believe,
that it does not apply to my case, since is a requirement, that
certain connections must go through certain interfaces.

Hopefully, I've managed to express my question adequately.

Is there anything that could be done? I see, that I could define
LWIP_HOOK_IP4_ROUTE, but, unfortunately, it does not receive the
source address as an argument, so that would not work.

Maybe, I am missing something obvious?

Thanks in advance,
Mark

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


Re: [lwip-users] Sending to a non-local network without default netif set

2014-08-07 Thread Simon Goldschmidt
Mark Lvov wrote:

 [..] certain connections must be opened via a particular
 interface. I was trying to achieve that by binding to an address-port
 prior to connecting, where the address corresponds to an address of a
 particular interface.
 [..]
 Is there anything that could be done? I see, that I could define
 LWIP_HOOK_IP4_ROUTE, but, unfortunately, it does not receive the
 source address as an argument, so that would not work.
 
 Maybe, I am missing something obvious?

I don't think you missed something obvious other than that lwIP wasn't meant to 
support the things you want to do. The routing hook you found was meant to 
support better routing, but it might not be enough for you.

In cases like this, ask yourself how would you write the same application on 
windows or Linux? Normally you'd have to adjust the routing table. And at least 
on windows, IPv4 routing takes the target address only. So you'd have to set up 
a routing table for all your target addresses and use it to decide in your 
routing hook function without the need of binding to a local IP address of one 
of the interfaces. Wouldn't that work? Aren't the destination addresses unique 
for your application?

Simon

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users


Re: [lwip-users] Sending to a non-local network without default netif set

2014-08-07 Thread Mark Lvov
Thanks for the great suggestion, Simon!

Yes, what you suggest would work.. almost! Indeed, the destination
addresses are there in the configuration (along with the interfaces
associated with those destinations), so, theoretically, I could indeed
route based on destination address only. Problem is, its not the
destination address, but the address-port tuple. I am not sure how
probable is the configuration where you have similar destination
addresses associated with different network interfaces, but it
certainly is possible and I can not really enforce the uniqueness of
destination addresses. So, while this is definitely a good way to
handle multihomed configurations in general, I'll have to do it some
other way.

Perhaps, I'll borrow the idea from this bug report:
http://savannah.nongnu.org/bugs/?34683

Thanks again.

Mark

On Fri, Aug 8, 2014 at 12:11 AM, Simon Goldschmidt goldsi...@gmx.de wrote:
 Mark Lvov wrote:

 [..] certain connections must be opened via a particular
 interface. I was trying to achieve that by binding to an address-port
 prior to connecting, where the address corresponds to an address of a
 particular interface.
 [..]
 Is there anything that could be done? I see, that I could define
 LWIP_HOOK_IP4_ROUTE, but, unfortunately, it does not receive the
 source address as an argument, so that would not work.

 Maybe, I am missing something obvious?

 I don't think you missed something obvious other than that lwIP wasn't meant 
 to support the things you want to do. The routing hook you found was meant to 
 support better routing, but it might not be enough for you.

 In cases like this, ask yourself how would you write the same application on 
 windows or Linux? Normally you'd have to adjust the routing table. And at 
 least on windows, IPv4 routing takes the target address only. So you'd have 
 to set up a routing table for all your target addresses and use it to decide 
 in your routing hook function without the need of binding to a local IP 
 address of one of the interfaces. Wouldn't that work? Aren't the destination 
 addresses unique for your application?

 Simon

 ___
 lwip-users mailing list
 lwip-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/lwip-users

___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users