This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TDA2PXEVM: How to create two vlan socket that bind same IP but different vlan-id?

Part Number: TDA2PXEVM

[TDA2PX]How to create two vlan socket that bind same IP but different vlan-id? (TI-RTOS)

we have already added two vlan by VLANAddDevice, the default usage for vlan is bind to different IP address, we also send data success with different vlan-id socket that bind with different IP address

but we need to create two vlan socket with different vlan-id that bind same IP address and this config is failure

1. we need send RTP on vlan id 5 with IP("198.18.36.96")
2. we need send other data on vlan id 12 with IP("198.18.36.96")
but the NDK seems not support the two configs working at same time, we can not create one socket(vlan5) for sending RTP while create another(vlan12) for sending data, so how to solve this?

code:

m_eth_elan = 1;
int m_eth_vlan5 = eth_vlan_add(5,2);
int m_eth_vlan12 = eth_vlan_add(12,0);
nt_print("m_eth_elan(real port):%d m_eth_vlan5(vlan port):%d m_eth_vlan12(vlan port):%d",m_eth_elan,m_eth_vlan5,m_eth_vlan12);

eth_dev_ifconfig(m_eth_elan, (uint8_t*)("198.18.36.96"), (uint8_t*)("255.255.0.0"), NULL);
eth_dev_ifconfig(m_eth_vlan5, (uint8_t*)("198.18.36.96"), (uint8_t*)("255.255.0.0"), NULL);
eth_dev_ifconfig(m_eth_vlan12, (uint8_t*)("198.18.36.96"), (uint8_t*)("255.255.0.0"), NULL);

log

network session start
eth_vlan_add tagid:5 priority:2
eth_vlan_add VLANAddDevice ret:2
eth_vlan_add tagid:12 priority:0
eth_vlan_add VLANAddDevice ret:3
m_eth_elan(real port):1 m_eth_vlan5(vlan port):2 m_eth_vlan12(vlan port):3ifconfig eth index:1 name:eth0 mtu:1500 addr:198.18.36.96 mask:255.255.0.0
ifconfig eth index:1 success
ifconfig eth index:2 name:eth0:5 mtu:1496 addr:198.18.36.96 mask:255.255.0.0
ifconfig eth index:2 CfgAddEntry failure, ret_code:-101
ifconfig eth index:3 name:eth0:12 mtu:1496 addr:198.18.36.96 mask:255.255.0.0
ifconfig eth index:3 CfgAddEntry failure, ret_code:-101

  • code
    m_eth_elan = 1;
    int m_eth_vlan5 = eth_vlan_add(5,2);
    int m_eth_vlan12 = eth_vlan_add(12,0);
    nt_print("m_eth_elan(real port):%d m_eth_vlan5(vlan port):%d m_eth_vlan12(vlan port):%d\n",m_eth_elan,m_eth_vlan5,m_eth_vlan12);

    eth_dev_ifconfig(m_eth_elan, (uint8_t*)("198.18.36.96"), (uint8_t*)("255.255.0.0"), NULL);
    eth_dev_ifconfig(m_eth_vlan5, (uint8_t*)("198.18.5.96"), (uint8_t*)("255.255.0.0"), NULL);
    eth_dev_ifconfig(m_eth_vlan12, (uint8_t*)("198.18.12.96"), (uint8_t*)("255.255.0.0"), NULL);

    log
    eth_vlan_add tagid:5 priority:2
    eth_vlan_add VLANAddDevice ret:2
    eth_vlan_add tagid:12 priority:0
    eth_vlan_add VLANAddDevice ret:3
    m_eth_elan(real port):1 m_eth_vlan5(vlan port):2 m_eth_vlan12(vlan port):3
    ifconfig eth index:1 name:eth0 mtu:1500 addr:198.18.36.96 mask:255.255.0.0
    ifconfig eth index:1 success
    ifconfig eth index:2 name:eth0:5 mtu:1496 addr:198.18.5.96 mask:255.255.0.0
    ifconfig eth index:2 CfgAddEntry failure, ret_code:-101
    ifconfig eth index:3 name:eth0:12 mtu:1496 addr:198.18.12.96 mask:255.255.0.0
    ifconfig eth index:3 CfgAddEntry failure, ret_code:-101
  • code
    m_eth_elan = 1;
    int m_eth_vlan5 = eth_vlan_add(5,2);
    int m_eth_vlan12 = eth_vlan_add(12,0);
    nt_print("m_eth_elan(real port):%d m_eth_vlan5(vlan port):%d m_eth_vlan12(vlan port):%d\n",m_eth_elan,m_eth_vlan5,m_eth_vlan12);

    eth_dev_ifconfig(m_eth_elan, (uint8_t*)("198.18.36.96"), (uint8_t*)("255.255.0.0"), NULL);
    eth_dev_ifconfig(m_eth_vlan5, (uint8_t*)("198.5.36.96"), (uint8_t*)("255.255.0.0"), NULL);
    eth_dev_ifconfig(m_eth_vlan12, (uint8_t*)("198.12.36.96"), (uint8_t*)("255.255.0.0"), NULL);


    log

    eth_vlan_add tagid:5 priority:2
    eth_vlan_add VLANAddDevice ret:2
    eth_vlan_add tagid:12 priority:0
    eth_vlan_add VLANAddDevice ret:3
    m_eth_elan(real port):1 m_eth_vlan5(vlan port):2 m_eth_vlan12(vlan port):3
    ifconfig eth index:1 name:eth0 mtu:1500 addr:198.18.36.96 mask:255.255.0.0
    ifconfig eth index:1 success
    ifconfig eth index:2 name:eth0:5 mtu:1496 addr:198.5.36.96 mask:255.255.0.0
    ifconfig eth index:2 success
    ifconfig eth index:3 name:eth0:12 mtu:1496 addr:198.12.36.96 mask:255.255.0.0
    ifconfig eth index:3 success
  • Hi Mi Zhou,

    I think the changes required in NDK to support this will be fairly large. I will consult our experts regarding the feasibility of this and get back to you.

    Regards,
    Anand
  • Hi Mi Zhou,

    We can have multiple VLAN Devices tied to a single NIMU IF. The VLANAddDevice() API takes the NIMU IF as a parameter. So you shouldn't be having any issues to do this. Anyways, just to clarify, the function you're using, eth_vlan_add(), is it a custom function? If yes, could you let me know what is the function signature, i.e, what are the arguments taken by the function? I believe it's a wrapper around the VLANAddDevice() API?

    Regards,
    Anand
  • Hi Mi Zhou,

    Haven't heard from you in a long time! I am assuming you were able to solve your issue. Please let me know of the status so that I can close the thread :)

    Regards,
    Anand
  • Hi Anand
    eth_vlan_add is baseon VLANAddDevice and this has no issue, but after the vlan interface is added, the two valn interface and the one real interface can not share the same ip address, please check my three example logs above carefully!

    I want the thee interfaces use same ip "198.18.36.96" in same subnet, but it seems failure.


    ===============
    eth_dev_ifconfig(m_eth_elan, (uint8_t*)("198.18.36.96"), (uint8_t*)("255.255.0.0"), NULL);
    eth_dev_ifconfig(m_eth_vlan5, (uint8_t*)("198.18.36.96"), (uint8_t*)("255.255.0.0"), NULL);
    eth_dev_ifconfig(m_eth_vlan12, (uint8_t*)("198.18.36.96"), (uint8_t*)("255.255.0.0"), NULL);

    ifconfig eth index:1 name:eth0 mtu:1500 addr:198.18.36.96 mask:255.255.0.0
    ifconfig eth index:1 success
    ifconfig eth index:2 name:eth0:5 mtu:1496 addr:198.18.36.96 mask:255.255.0.0
    ifconfig eth index:2 CfgAddEntry failure, ret_code:-101
    ifconfig eth index:3 name:eth0:12 mtu:1496 addr:198.18.36.96 mask:255.255.0.0
    ifconfig eth index:3 CfgAddEntry failure, ret_code:-101
  • Hi Anand
    eth_vlan_add is baseon VLANAddDevice and this has no issue, but after the vlan interface is added, the two valn interface and the one real interface can not share the same ip address, please check my three example logs above carefully!

    I want the thee interfaces use same ip "198.18.36.96" in same subnet, but it seems failure.


    ===============
    eth_dev_ifconfig(m_eth_elan, (uint8_t*)("198.18.36.96"), (uint8_t*)("255.255.0.0"), NULL);
    eth_dev_ifconfig(m_eth_vlan5, (uint8_t*)("198.18.36.96"), (uint8_t*)("255.255.0.0"), NULL);
    eth_dev_ifconfig(m_eth_vlan12, (uint8_t*)("198.18.36.96"), (uint8_t*)("255.255.0.0"), NULL);

    ifconfig eth index:1 name:eth0 mtu:1500 addr:198.18.36.96 mask:255.255.0.0
    ifconfig eth index:1 success
    ifconfig eth index:2 name:eth0:5 mtu:1496 addr:198.18.36.96 mask:255.255.0.0
    ifconfig eth index:2 CfgAddEntry failure, ret_code:-101
    ifconfig eth index:3 name:eth0:12 mtu:1496 addr:198.18.36.96 mask:255.255.0.0
    ifconfig eth index:3 CfgAddEntry failure, ret_code:-101
  • Hi Mi Zhou,

    From your log, it says that ifconfig eth index:1, 2, 3 etc. If you are trying to add vlan interfaces to a single interface index with single IP, shouldn't you be having for all of them the same index? Or is it just a loop variable? Correct me if I'm wrong, but I can't see where do you configure that the vlan interface corresponds to a specific NIMU IF.

    Regards,
    Anand
  • Hi Anand
    how to configure the vlan interface to the NIMU IF? in example 3, I just assign the device with different subnet ip address, the config success, so I think if I create a vlan device, the NIMU IF is also created.

    ============================================================
    I first create vlan device base on real device, then assign the ip address to the created device, your answer (use VLANAddDevice) is just create the vlan device, not including assign the ip address to the device

    first create vlanx base on real mac port index 1 (in my point view, the real index is baseon which port your hardware connect, if you connect to another mac port, the index is 0), if the create success, I can get the vlan device index baseon real port index, then config the ip address with each device index.

    ============================================================
    code

    m_eth_elan = 1; ===>this is the real hardware mac index 1 which means I use the real mac index
    int m_eth_vlan5 = eth_vlan_add(5,2); ===> add vlan 5 in real index 1 with VLANAddDevice, then it returns the vlan5's index 2 (increase baseon 1)
    int m_eth_vlan12 = eth_vlan_add(12,0); ===> same add vlan 12 baseon real index 1, then it returns the vlan12's index 3 (increase baseon 2)

    //print the all device index
    nt_print("m_eth_elan(real port):%d m_eth_vlan5(vlan port):%d m_eth_vlan12(vlan port):%d",m_eth_elan,m_eth_vlan5,m_eth_vlan12);

    //config real port ip address which index is 1
    eth_dev_ifconfig(m_eth_elan, (uint8_t*)("198.18.36.96"), (uint8_t*)("255.255.0.0"), NULL);

    //config vlan5 port ip address which index is 2
    eth_dev_ifconfig(m_eth_vlan5, (uint8_t*)("198.18.36.96"), (uint8_t*)("255.255.0.0"), NULL);

    //config vlan12 port ip address which index is 3
    eth_dev_ifconfig(m_eth_vlan12, (uint8_t*)("198.18.36.96"), (uint8_t*)("255.255.0.0"), NULL);

    ==========================================
    log

    //add vlan success
    eth_vlan_add tagid:5 priority:2
    eth_vlan_add VLANAddDevice ret:2
    eth_vlan_add tagid:12 priority:0
    eth_vlan_add VLANAddDevice ret:3

    //ifconfig real port index 1 success
    m_eth_elan(real port):1 m_eth_vlan5(vlan port):2 m_eth_vlan12(vlan port):3ifconfig eth index:1 name:eth0 mtu:1500 addr:198.18.36.96 mask:255.255.0.0
    ifconfig eth index:1 success

    //ifconfig vlan5 port index 2 failure
    ifconfig eth index:2 name:eth0:5 mtu:1496 addr:198.18.36.96 mask:255.255.0.0
    ifconfig eth index:2 CfgAddEntry failure, ret_code:-101

    //ifconfig vlan12 port index 3 failure
    ifconfig eth index:3 name:eth0:12 mtu:1496 addr:198.18.36.96 mask:255.255.0.0
    ifconfig eth index:3 CfgAddEntry failure, ret_code:-101

    ============================================================
    the log above failure, buf if I config as below(differnet subnet ip address), the config success
    eth_dev_ifconfig(m_eth_elan, (uint8_t*)("198.18.36.96"), (uint8_t*)("255.255.0.0"), NULL);
    eth_dev_ifconfig(m_eth_vlan5, (uint8_t*)("198.5.36.96"), (uint8_t*)("255.255.0.0"), NULL);
    eth_dev_ifconfig(m_eth_vlan12, (uint8_t*)("198.12.36.96"), (uint8_t*)("255.255.0.0"), NULL);
  • Hi Mi Zhou,

    In your method, you are creating a NIMU IF for each of the vlan devices you create. That defeats the purpose of having the vlan interfaces attached to a single interface with single IP. Instead, create vlan ids, and then use VLANAddDevice() API to add the vlan device to the NIMU IF. Configure the IP address for single NIMU IF separately first, and then do the VLAN stuff. I'm not sure why do you use wrappers on top of already available APIs.

    Regards,
    Anand
  • Hi Anand
    ============================================================
    Instead, create vlan ids, and then use VLANAddDevice() API to add the vlan device to the NIMU IF
    I not create the vlan ids, the vlan id is the return value from [VLANAddDevice]

    ============================================================
    I'm not sure why do you use wrappers on top of already available APIs
    I use wrappers because I want to use these APIs as a module, in fact, all the codes are copyed from ndk, [eth_vlan_add] call [VLANAddDevice] and [eth_dev_ifconfig] call [CfgAddEntry], you can see this from the log.

    ============================================================
    It is no matter what code I used, I just want create different sockets in different vlan with same ip address, could you give me the sample code?
    1. we need send RTP on vlan id 5 with IP("198.18.36.96") ===>the socket packet must contains vlan tagid 5
    2. we need send other data on vlan id 12 with IP("198.18.36.96")===>the socket packet must contains vlan tagid 12
  • Hello Anand,

    Could you help to provide an example codes of your proposal setting steps? It will be better and helpful if you have tested this setting successfully.
  • Hi Yong,

    I think it would be better to try out the suggestion first, as we are yet to test this feature. Also, since you're using wrapper APIs, I'm not sure if the sample code would be helpful.

    Regards,
    Anand
  • Hi Anand,
    Here is some information which may help:
    1) eth_vlan_add() API is replica of CmdVLANAdd() API in ndk_2_24_02_31/packages/ti/ndk/tools/console/convlan.c
    2) eth_vlan_add() is trying to add a vlan device to single source interface every time it is called. Its arguments are i) vlan id and ii) priority.

    So what was tried is to create two vlan devices using same source interface and then assign ip address to them.

    Will it be possible for you to create a test function based on APIs in convlan.c to demonstrate how to create multiple vlan ids on same ip address.

    Thanks a lot,
    Ravikant
  • Hi Ravikant,

    Instead of calling CmdVLANAdd(), you could directly use VLANAddDevice() which takes src_index, vlan_id, priority etc. Also, assigning the IP address can be done separately even before adding vlan devices. Please don't use CfgAddEntry to assign IPs. The API creates a new interface altogether. I think the assigning of IPs is already taken care. So VLANAddDevice() can be just called, with the src_index as say, 0 for different vlan ids to tie different devices to the same IP. I will try to reproduce the setup in my side and try it out too.

    Regards,
    Anand
  • I understand that this issue is being discussed in other means of support. Let's continue the issue there.

    Regards,
    Anand