You've already forked mariadb-columnstore-engine
							
							
				mirror of
				https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
				synced 2025-11-03 17:13:17 +03:00 
			
		
		
		
	MCOL-547 - change to check for multiple ip address matches
This commit is contained in:
		@@ -53,10 +53,11 @@
 | 
			
		||||
#include <glob.h>
 | 
			
		||||
 | 
			
		||||
#include <arpa/inet.h>
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <ifaddrs.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <string.h> /* for strncpy */
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <sys/ioctl.h>
 | 
			
		||||
#include <netinet/in.h>
 | 
			
		||||
#include <net/if.h>
 | 
			
		||||
@@ -438,32 +439,40 @@ int main(int argc, char *argv[])
 | 
			
		||||
    try
 | 
			
		||||
    {
 | 
			
		||||
        oam.getSystemConfig("pm1", moduleconfig);
 | 
			
		||||
        if (moduleconfig.hostConfigList.size() > 0 )
 | 
			
		||||
        {
 | 
			
		||||
            HostConfigList::iterator pt1 = moduleconfig.hostConfigList.begin();
 | 
			
		||||
            string PM1ipAdd = (*pt1).IPAddr;
 | 
			
		||||
            cout << PM1ipAdd << endl;
 | 
			
		||||
 | 
			
		||||
        if ( PM1ipAdd != "127.0.0.1")
 | 
			
		||||
            if ( PM1ipAdd != "127.0.0.1" && PM1ipAdd != "0.0.0.0")
 | 
			
		||||
            {
 | 
			
		||||
            // now get the local ip address
 | 
			
		||||
                        int fd;
 | 
			
		||||
            struct ifreq ifr;
 | 
			
		||||
                struct ifaddrs *ifap, *ifa;
 | 
			
		||||
                struct sockaddr_in *sa;
 | 
			
		||||
                char *addr;
 | 
			
		||||
                bool found = false;
 | 
			
		||||
 | 
			
		||||
            fd = socket(AF_INET, SOCK_DGRAM, 0);
 | 
			
		||||
                getifaddrs (&ifap);
 | 
			
		||||
                for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
 | 
			
		||||
                    if (ifa->ifa_addr->sa_family==AF_INET) {
 | 
			
		||||
                        sa = (struct sockaddr_in *) ifa->ifa_addr;
 | 
			
		||||
                        addr = inet_ntoa(sa->sin_addr);
 | 
			
		||||
                        printf("Interface: %s\tAddress: %s\n", ifa->ifa_name, addr);
 | 
			
		||||
 | 
			
		||||
            /* I want to get an IPv4 IP address */
 | 
			
		||||
            ifr.ifr_addr.sa_family = AF_INET;
 | 
			
		||||
                        if ( PM1ipAdd == addr )
 | 
			
		||||
                        {
 | 
			
		||||
							//match
 | 
			
		||||
                            found = true;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
            /* I want IP address attached to "eth0" */
 | 
			
		||||
            strncpy(ifr.ifr_name, "eth0", IFNAMSIZ-1);
 | 
			
		||||
                    if (found)
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            ioctl(fd, SIOCGIFADDR, &ifr);
 | 
			
		||||
                freeifaddrs(ifap);
 | 
			
		||||
 | 
			
		||||
            close(fd);
 | 
			
		||||
 | 
			
		||||
            string localIPAddr = inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr);
 | 
			
		||||
 | 
			
		||||
            if ( PM1ipAdd != localIPAddr )
 | 
			
		||||
            // configure pm1 and local ip address don't match, error out
 | 
			
		||||
            // can only install from pm1
 | 
			
		||||
                if (!found)
 | 
			
		||||
                {
 | 
			
		||||
                    cout << endl;
 | 
			
		||||
                    cout << "ERROR: postConfigure install can only be done on the PM1" << endl;
 | 
			
		||||
@@ -473,10 +482,12 @@ int main(int argc, char *argv[])
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    catch(...)
 | 
			
		||||
    {}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	// run my.cnf upgrade script
 | 
			
		||||
	if ( reuseConfig == "y" )
 | 
			
		||||
	{
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user