Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

Multiple IPs for one Ethernet Port

Hi,

In my application I would like to have multiple IP address attached to the same ethernet MAC (one MAC address). Obviously, the IPs will not occupy the same subnets - for a given subnet mask (same for all the interfaces)Subnet mask = 255.255.0.0, IP1=192.168.0.1, IP2=192.169.0.1, IP3=192.170.0.1.

In my experience, the Trek stack allows me to make multiple interface like the one above, but the Niche stack "binds" one IP address to one MAC address (I may be wrong here). I found that the alt_iniche_device_list which determines the if_count variable depends on the number of Ethernet devices (TRIPLE_SPEED_ETHERNET_INIT(..) -> alt_iniche_dev_reg(..)).

Is there a way this can be done in uC/OS + NicheStack without modifying the stack code?

Also, has anyone used the "supplemental MAC address" capability of the TSE MAC to assign more than one MAC address to the TSE MAC? How do you make it work with the NicheStack?

BTW, I found slightly better documentation of the NicheStack on the ARM website...

-Ravi

4 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Ravi!!!

    I've just finishied patching Nichestack in order to support multiple IP address (also on different subnet :)). Up to know I've tested ping service to 3 different IPs (and subnet, etc...) and it works. I've also tested Telnet Server to 3 different IPs and it works!!!

    Now I'm going to test FTP server...

    I've just modified ARP and IP layer implementing IP filtering with a list of supported IPs.

    I think that this patch would work only with SERVER services, but I'm not sure about it...

    Ciao
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Paolo,

    That's nice. Can you give me some pointers on how you managed this? I was looking at changing the NicheStack code so that a number of interfaces can be opened (statically, at startup), attached to the same physical port. For this to happen, I am changing the driver software (ins_tse_mac.c) to open up 4 interfaces (modify the init procedure) and then change the stack code (demux.c) to confirm that the interface variable in the NET structure is set correctly - for a Rx packet. To allow me to use socket calls (sendto and recvfrom), I am adding a socket option that would set the interface number for the socket - so that I can send out Tx packets on the proper interface (having the correct IP address). This would allow me to have a general-purpose fix rather than just a "server" services as you mentioned. All this is fairly intrusive and i thought Interniche (or someone else) must have done this already. I still need to demux the packet to the correct socket (on the rx side). I will take a look at the IP filtering code. One other reason for making the changes "interface" based is that I can then use the same code for multiple MAC addresses (using the supplemental addresses of the TSE) or use VLAN capabilities - a unique interface for one VLAN tag or a unique MAC address. What do you think? Any suggestions?

    -Ravi
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Ravi,

    when I faced the necessity to support multiple IP addresses I didn't thought that was possible to open multiple interfaces; Nichestack documentation provides that is possible to have multiple interfaces (multi - homed) only if you have really more that one physical interfaces (they do the example with serial and phy devices). If you are trying to implement that solution I suppose that you verified it is possible; just for example check if is possible to handle 4 intefaces with 8 SGDMA and only one TSE.

    Anyway as you requested me I provide you where I modified Nichestack: basically everywhere IP address (and subnet, etc...) of received packet is checked comparing it with interface one. The rule I've followed is to substitute check on inteface IP address with a loop of check with my list of supported IP address (the first one is the copy of interface one).

    I modified ipport enabling USE_IPFILTER and then implemented ipf_filter function that is used within ip_rcv() in ipdemux.c.

    I modified arprcv() within et_arp.c adding multiple check where there was this line (if (arphdr->ar_tpa != pkt->net->n_ipaddr)

    I modified icmprcv() within icmp.c adding multiple check where there was this line

    if ((pip->ip_dest == 0xffffffff)

    I modified iproute() within ip.c adding multiple check where there was this line

    if((ifp->snmask != 0) && /* skip ifaces with no ip or subnet mask set */

    (ifp->n_ipaddr != 0) &&

    ((ifp->n_ipaddr & ifp->snmask) == (host & ifp->snmask)))

    I modified ip_rcv_phase2() within ipdemux.c adding multiple check where there was this line

    if ((pip->ip_dest != nt->n_ipaddr) && /* quick check on our own addr */

    (pip->ip_dest != 0xffffffffl) && /* physical cable broadcast addr*/

    (pip->ip_dest != nt->n_netbr) && /* all subnet broadcast */

    (pip->ip_dest != nt->n_netbr42) && /* all subnet bcast (4.2bsd) */

    (pip->ip_dest != nt->n_subnetbr) &&/* our subnet broadcast */

    (nt->n_ipaddr & ~nt->snmask)) /* know our own host address? */

    I modified udpdemux() within udp.c adding multiple check where there was this line

    if ((pip->ip_dest == 0xffffffffl) || /* physical cable broadcast addr*/

    (pip->ip_dest == p->net->n_netbr) || /* all subnet broadcast */

    (pip->ip_dest == p->net->n_netbr42) || /* all subnet bcast (4.2bsd) */

    (pip->ip_dest == p->net->n_subnetbr)) /* our subnet broadcast */

    That's all I've modified! Up to now it seems to work and I didn't need to modify anything else.

    About multiple MAC address I can't answer you anything because I didn't have the necessity to support that feature...

    Let me know if my suggestion was useful and eventually if you find some other point where my kind of modifications are required.

    Good luck!

    Paolo
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Ravi,

    from today I'm back on multiple IPs support. This message is just to inform you that after few modifications, my modified stack is now able to handle multiple FTP connections handled by multiple FTP server. The important thing is that I can manage both FTP active and passive activation mode.

    Ciao,

    Paolo