4 Replies Latest reply: Nov 22, 2011 3:06 AM by 900255 RSS

    zoneid field of ifreq structure is filling with the wrong zoneid in Solaris

    900255
      Hi,
      I have created three solaris zones. The IP-type of two of the zones are exclusive zone and the other is the exclusive zone.

      I have used getzonenamebyid function in my source code.
      When I am running my application in all these zones getzonenamebyid function failed in all the exclusive IP type zone.

      Please suggest me a best solution to come out of this error.

      Thanks,
      Radha.

      Edited by: 897252 on Nov 22, 2011 11:34 AM
        • 1. Re: getzonenamebyid failed in exclusive IP-type zones
          Mgerdts-Oracle
          You say that two are exclusive and so is the other one. I suspect that you mean to say that two are exclusive and one is shared. Are you by any chance running your program in one of the zones? While running in a (non-global) zone, it would be bug if you could see the other zones. If you are running in the global zone, you should be able to do the lookup.

          Consider this program:
          #include <stdio.h>
          #include <zone.h>
          #include <stdlib.h>
          #include <string.h>
          #include <errno.h>
          
          int
          main(int argc, char **argv)
          {
               int i;
               zoneid_t id;
               char name[MAXNAMELEN];
          
               for (i = 1; i < argc; i++) {
                    id = atoi(argv);

                    if (getzonenamebyid(id, name, sizeof (name)) == -1) {
                         fprintf(stderr, "zoneid %d: %s\n", id, strerror(errno));
                         continue;
                    }

                    printf("%d %s\n", id, name);
               }
          }
          After compiling it (cc -o getzonebyid getzonebyid.c), I can get the zoneid of each running zone with:
          $ zoneadm list -p | cut -d: -f1 | xargs ./getzonebyid
          0 global
          1 myzone
          If I pass it invalid zoneids, it fails with a reasonable error.
          $ ./getzonebyid 0 1 2 3
          0 global
          1 myzone
          zoneid 2: Invalid argument
          zoneid 3: Invalid argument
          Are you seeing something different?
          
          Edited by: mgerdts on Nov 17, 2011 4:06 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
          • 2. Re: getzonenamebyid failed in exclusive IP-type zones
            900255
            Hi Friend,
            Thanks for you reply. I am sorry for my unclear information. Now I have given clear information below.


            Here is the information of the machine where the problem is occurring :
            bash-3.00# uname -a
            SunOS lodsuncl1 5.10 Generic_141444-09 sun4u sparc SUNW,Sun-Fire-V240


            We have created three zones in my Solaris Sparc OS. The details of the zones are given below.

            1)     These are created as Whole root zone.
            2)     The IP type of the each is assigned as Shared
            bash-3.00# zoneadm list -iv
            ID NAME STATUS PATH BRAND IP
            0 global running / native shared
            23 lodsuncl1-a running /export/home/lodsuncl1-a native shared
            24 lodsuncl1-b running /export/home/lodsuncl1-b native shared
            25 lodsuncl1-c running /export/home/lodsuncl1-c native shared

            My application is running perfectly in all the zones. We have used getzonenamebyid function in our source code. In the above mentioned environment this function is running properly and returning the correct zonename.

            But in the below shown environment getzonenamebyid failed with Invalid argument.

            1)     Here also the zone is Whole root zone
            2)     But the IP type of each is assigned as Exclusive

            bash-3.00# zoneadm list -iv
            ID NAME STATUS PATH BRAND IP
            0 global running / native shared
            23 lodsuncl1-a running /export/home/lodsuncl1-a native excl
            24 lodsuncl1-b running /export/home/lodsuncl1-b native excl
            25 lodsuncl1-c running /export/home/lodsuncl1-c native excl

            So if the IP type is excl then getzonenamebyid failed. This function failed in all the zones except in global zone.
            Error is showing below

            0000188 2011-07-27 17:03:53.14 [W]-007- Net : AWTask():
            uxsA2_Net_SponGetAll() failed with error code -5: The operation failed
            0000189 2011-07-27 17:04:53.14 [C]-007- Net : uxsA2_Net_DPGetSpecific():
            getzonenamebyid failed for interface lo0! Error: Invalid argument


            My observation on this error

            I have applied debug statement for this error. Below is the output of debug statement
            getzonenamebyid has three arguments as shown in the below syntax.

            ssize_t getzonenamebyid(zoneid_t id, char *buf,   size_t      buflen);

            Before calling getzonenamebyid function I have observed what is the value of the zoneid is zero(0).

            The zoneid is filling from one of the field of ifreq structure which is the zoneid field. So ifreq structure is filling with zero(0).

            Value of zero(0) is given to global zone id. But the value given to non-global zones are 23,24, and 25. So getzonenamebyid is failed.
            Conclusion

            Thezoneid field of Ifreq structure should not fill with zero for the solaris zones. It should fill with the appropriate value of zone. In the above shown case it should fill lifru_zoneid with 23 for lodsuncl1-a zone.
            should fill lifru_zoneid with 24 for lodsuncl1-b zone.
            should fill lifru_zoneid with 25 for lodsuncl1-c zone.

            Showing the ifreq structure zoneid field.
            lifru_groupname = ""
            lifru_delay = 0
            lifru_zoneid = 0
            }

            So I understood that why the getzonenamebyid is failing. So please suggest me asolution to overcome this problem


            Thanks
            Radha.
            • 3. Re: getzonenamebyid failed in exclusive IP-type zones
              Mgerdts-Oracle
              897252 wrote:
              Hi Friend,
              Thanks for you reply. I am sorry for my unclear information. Now I have given clear information below.


              Here is the information of the machine where the problem is occurring :
              bash-3.00# uname -a
              SunOS lodsuncl1 5.10 Generic_141444-09 sun4u sparc SUNW,Sun-Fire-V240


              We have created three zones in my Solaris Sparc OS. The details of the zones are given below.

              1)     These are created as Whole root zone.
              2)     The IP type of the each is assigned as Shared
              bash-3.00# zoneadm list -iv
              ID NAME STATUS PATH BRAND IP
              0 global running / native shared
              23 lodsuncl1-a running /export/home/lodsuncl1-a native shared
              24 lodsuncl1-b running /export/home/lodsuncl1-b native shared
              25 lodsuncl1-c running /export/home/lodsuncl1-c native shared

              My application is running perfectly in all the zones. We have used getzonenamebyid function in our source code. In the above mentioned environment this function is running properly and returning the correct zonename.

              But in the below shown environment getzonenamebyid failed with Invalid argument.

              1)     Here also the zone is Whole root zone
              2)     But the IP type of each is assigned as Exclusive

              bash-3.00# zoneadm list -iv
              ID NAME STATUS PATH BRAND IP
              0 global running / native shared
              23 lodsuncl1-a running /export/home/lodsuncl1-a native excl
              24 lodsuncl1-b running /export/home/lodsuncl1-b native excl
              25 lodsuncl1-c running /export/home/lodsuncl1-c native excl

              So if the IP type is excl then getzonenamebyid failed. This function failed in all the zones except in global zone.
              Error is showing below

              0000188 2011-07-27 17:03:53.14 [W]-007- Net : AWTask():
              uxsA2_Net_SponGetAll() failed with error code -5: The operation failed
              0000189 2011-07-27 17:04:53.14 [C]-007- Net : uxsA2_Net_DPGetSpecific():
              getzonenamebyid failed for interface lo0! Error: Invalid argument


              My observation on this error

              I have applied debug statement for this error. Below is the output of debug statement
              getzonenamebyid has three arguments as shown in the below syntax.

              ssize_t getzonenamebyid(zoneid_t id, char *buf,   size_t      buflen);

              Before calling getzonenamebyid function I have observed what is the value of the zoneid is zero(0).

              The zoneid is filling from one of the field of ifreq structure which is the zoneid field. So ifreq structure is filling with zero(0).
              This is not a problem with getzonenamebyid() it is potentially a problem with the ifreq structure returned by ioctl(fd, SIOCGLIFZONE) or similar contains lifru_zoneid = 0. I say potentially a problem, as I do not know the intent or design decisions behind that field in struct ifreq as it relates to exclusive stack zones.

              >
              Value of zero(0) is given to global zone id. But the value given to non-global zones are 23,24, and 25. So getzonenamebyid is failed.
              It failed with EINVAL, which is exactly what it should do when it doesn't have access to that zoneid. In a zone, the zone only has access to information about itself.
              Conclusion

              Thezoneid field of Ifreq structure should not fill with zero for the solaris zones. It should fill with the appropriate value of zone. In the above shown case it should fill lifru_zoneid with 23 for lodsuncl1-a zone.
              should fill lifru_zoneid with 24 for lodsuncl1-b zone.
              should fill lifru_zoneid with 25 for lodsuncl1-c zone.
              That seems like a reasonable assumption, given what if_tcp(7P) says. I'm just not sure if there is some other detail lurking as to why it is the way it is. I almost think there is, as there is a fixed bug:

              6852739 mdnsd doesn't recognize valid IP addresses in exclusive stack zones

              where the fix was to mdnsd, not to the system call behind SIOCGLIFZONE. A comment added with that fix gets to a suggestion I was going to make: If you are running in a zone, any interface that you see should be associated with that zone. Thus, if you are running in a zone, the name of the zone that has access to it is the one given by zonename(1) or
              getzonenamebyid(getzoneid(), name, sizeof (name)).

              >
              Showing the ifreq structure zoneid field.
              lifru_groupname = ""
              lifru_delay = 0
              lifru_zoneid = 0
              }

              So I understood that why the getzonenamebyid is failing. So please suggest me asolution to overcome this problem


              Thanks
              Radha.
              It's important to frame this as the right problem so that it can be directed at the right team. If you say that getzonenamebyid() is failing, it will end up with people that know a lot about zones. If you say that an interface documented in if_tcp(7p) is giving back the wrong answer but only in zones, it will be directed at people that know a lot about networking and its interaction with zones. I'd suggest opening a support call to get this directed to the right group.

              To get to a workaround, perhaps you can share what it is that you are trying to accomplish? Do you really need to know the zone associated with an interface, or are you trying to get to something else?
              • 4. Re: ifreq structure is filling with the wrong zoneid
                900255
                Hi Friend,
                Thanks for your clear information. I have opened a ticket with Oracle support. I am waiting for the reply from them.

                As you said I have given the wrong subject. Now the subject corrected prorperly for this post.


                I need to give this fix for one of our customer.

                Thanks,
                Radha.