On 10/25/2023 9:27 AM, Matthias Roosz wrote:
Hi all,



forgive my ignorance, I’ve just started diving into networking topics
(including handling connections via Berkeley sockets). My final goal is to
make my device reachable via two separate IP addresses with a single PHY.
Once there are two IP addresses set up I'd bind to each specific address to
get two socket handles with which my application could work - does that
make sense (the use case would be in connection with an integrated switch,
e.g. a KSZ8463)?

In linux systems I think this can be achieved via ifconfig eth0:0
[newAddress] netmask [mask] up or by persisting the configuration in
/etc/network/interfaces (i.e. in my understanding by creating an alias
network interface).
I think you would need to implement something like this in NuttX too.
Now in Nuttx ifconfig does not allow this and there is no persistent
configuration. I can't imaging calling netlib_set_ipv4addr() /
netlib_set_dripv4addr () / netlib_set_ipv4netmask() twice with the same
ifname will work so the question remains: how do I get a second interface I
can work with? Do I even need to integrate more potent hardware such as a
KSZ9477S that has multiple physical GMACS?

The network interface is controlled by the network MAC driver. Its device structure carries the IP address and netmask that are associated with the MAC via IOCTLs, but I don't think that the driver itself knows anything about IP (it shouldn't!)

The IP address and netmask normally defines a subnet and, hence, the network.  Normally two IP addresses would reside on the same network.  In this case do you want to support two different IP address from different networks?  I hope not (only because I don't understand that model, perhaps it doesn't matter to the software).

The IP routing is purely based on the IP address stored in the device structure.  If you want routing to two different address on the subnet, then you would need two IP address in the device structure.  Again, these should have nothing to do with the MAC driver.  You would need (1) a network IOCTL and NSH ifconfig extension to set the second IP address (following the Linux convention), and (2) logic throughout the network code to handle the second address.  The IP routing is one place, but there are lots of others.  In most of these, where the first IP address is referenced, you would need to add logic to use the first IP address OR the second IP address.  This would mean both IPv4 and IPv6.

Supporting the second address has size/performance implications and probably should be a Kconfig option.

That would be a significant effort, but not overwhelmingly impossible.


Reply via email to