AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.

 View Only
Expand all | Collapse all

getifaddrs

  • 1.  getifaddrs

    Posted 7 days ago

    Does this return on all tha associated IPs on the same interface, When I checked it's only returning the primary one...?



    ------------------------------
    Murarisetty guptha
    ------------------------------


  • 2.  RE: getifaddrs

    Posted 6 days ago

    Hi Murarisetty,

    I think I am missing a context here. What do you mean? The C function getifaddrs()? As far as I know, it doesn't exist on AIX in the standard package. Can you give more details what you want to achieve?



    ------------------------------
    Andrey Klyachkin

    https://www.power-devops.com
    ------------------------------



  • 3.  RE: getifaddrs

    Posted 6 days ago


    hey Andrey, I want to achieve the list of all active IP's  on particular interface
    From below I want to get both the IP's(10.30.4.70,10.30.4.71) for one use case for my server, to get the IP's I was using QNetworkInterface::allAddresses(); and it's working fine on LINUX but not working on AIX. I added some logs and it is returning only the first IP.

    en3: flags=1e084863,18c0<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),LARGESEND,CHAIN>
            inet 10.30.4.70 netmask 0xfffffe00 broadcast 10.30.5.255
            inet 10.30.4.71 netmask 0xa1e05ff broadcast 255.255.254.71
             tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1



    ------------------------------
    Murarisetty guptha
    ------------------------------



  • 4.  RE: getifaddrs

    Posted 6 days ago

    Does that second address work? Can you connect to it?
    inet 10.30.4.71 netmask 0xa1e05ff broadcast 255.255.254.71

    The netmask looks bad.



    ------------------------------
    Alexander Pettitt
    ------------------------------



  • 5.  RE: getifaddrs

    Posted 6 days ago

    Something like this I am getting as response, sry I don't have much knowledge on this.

    val@laulpar06:/oams/v_syb_aix_1/aaa/current/msg > ping 10.30.4.71
    PING 10.30.4.71 (10.30.4.71): 56 data bytes
    64 bytes from 10.30.4.71: icmp_seq=0 ttl=255 time=0 ms
    64 bytes from 10.30.4.71: icmp_seq=1 ttl=255 time=0 ms
    64 bytes from 10.30.4.71: icmp_seq=2 ttl=255 time=0 ms
    64 bytes from 10.30.4.71: icmp_seq=3 ttl=255 time=0 ms



    ------------------------------
    Murarisetty guptha
    ------------------------------



  • 6.  RE: getifaddrs

    Posted 6 days ago

    The netmask is beyond bad: it's 10.30.5.255, so I'm guessing someone (or some script) picked the broadcast address and stored it in the netmask.



    ------------------------------
    José Pina Coelho
    IT Specialist at Kyndryl
    ------------------------------



  • 7.  RE: getifaddrs

    Posted 6 days ago

    Hi Andrey, it seems to be a recent addition to AIX.  Either to be compatible with BSD or glibc.

    I find it in /usr/lib/libifaddrs.{a,exp} - exporting 2 symbols: getifaddrs, freeifaddrs - on AIX 7300-03-00-2446 and 7300-02-02-2420.  It's provided by bos.net.tcp.server_core, but not documented.

    From it's history: 

    This function first appeared in BSDi and is
    present on the BSD systems, but with slightly different
    semantics documented\[em]returning one entry per interface,
    not per address.


    https://linux.die.net/man/3/getifaddrs 
    https://man.freebsd.org/cgi/man.cgi?getifaddrs



    ------------------------------
    José Pina Coelho
    IT Specialist at Kyndryl
    ------------------------------



  • 8.  RE: getifaddrs

    Posted 6 days ago

    HI Jose, I understood but my concern is why in AIX, not able to list all IPs on the same interface,

    Those IPs are dummy one's and I tested the same in LINUX, we are able to get all the list of IP's and then I can use for my server

    QNetworkInterface::allAddresses();, This is what I was using earlier on my Linux machine



    ------------------------------
    Murarisetty guptha
    ------------------------------



  • 9.  RE: getifaddrs

    Posted 5 days ago

    Hi Murarisetty,

    QNetworkInterface is a part of QT5, and is coded in C++, which I don't know well enough to track all the way to the system libraries, but if allAdresses is returning the same information as getifaddrs, then it either is using getifaddrs or it is probably being tripped by the same thing that trips getifaddrs.

    Take a small C program like the one in Andrey's post and test it, then open a case with IBM and tell them you have a small testcase that shows the problem.

    Don't forget to mention that the '*.h' file is missing. 



    ------------------------------
    José Pina Coelho
    IT Specialist at Kyndryl
    ------------------------------



  • 10.  RE: getifaddrs

    Posted 6 days ago

    Hi José,

    thank you! Somehow, I missed it. I searched through the headers and didn't find any definitions for the function. Then I looked for exported symbols in libc.a, it was not there either. IBM decided to create a new library...

    I did a small test. I created the header file:

    #ifndef IFADDRS_H
    #define IFADDRS_H
    
    struct ifaddrs
    {
      struct ifaddrs   *ifa_next;
      char             *ifa_name;
      u_int             ifa_flags;
      struct sockaddr  *ifa_addr;
      struct sockaddr  *ifa_netmask;
      union
      {
        struct sockaddr *ifu_broadaddr;
        struct sockaddr *ifu_dstaddr;
      }  ifa_ifu;
      void             *ifa_data;
    };
    
    int getifaddrs(struct ifaddrs **ifap);
    void freeifaddrs(struct ifaddrs *ifap);
    
    #endif
    

    I've got the functions definitions from IBM i documentation - https://www.ibm.com/docs/en/i/7.1.0?topic=ssw_ibm_i_71/apis/getifaddrs.html

    Then I took the example from the IBM i documentation and compiled it on AIX 7.3 TL3.

    # gcc -o ifaddrs ifaddrs.c -lifaddrs
    

    The result is, as Murarisetty reported, without aliases. It shows only the first IP address on the interface.

    I took the same code to Linux. The only change - I don't need my getifaddrs.h on Linux. I can use the system file. It showed me the alias on the interface:

    Internet Address:  10.10.10.10 
    LineDescription :  ens192 
    Netmask         :  255.255.254.0 
    Broadcast Addr  :  10.10.10.255 
    
    Internet Address:  10.20.20.20 
    LineDescription :  ens192 
    Netmask         :  255.255.254.0 
    Broadcast Addr  :  10.20.20.20 
    

    Note that it shows the wrong broadcast address for the alias on Linux.

    It looks like the undocumented implementation of getifaddrs() on AIX is buggy. works as designed.

    Please open a ticket at IBM...



    ------------------------------
    Andrey Klyachkin

    https://www.power-devops.com
    ------------------------------



  • 11.  RE: getifaddrs

    Posted 6 days ago

    Hi Andrey,

    Could you please help us by creating the ticket with IBM? It would be a great help.
    Thanks in advance!

    Best regards,
    Murarisetty.



    ------------------------------
    Murarisetty guptha
    ------------------------------