chusiang / mysql-master-master

Automatically exported from code.google.com/p/mysql-master-master
GNU General Public License v2.0
1 stars 1 forks source link

Pattern matching needs fixing when parsing /sbin/ip addr show (from check_ip script) #35

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Start with a machine with very few IP addresses:

[root@localhost examples]# /sbin/ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 08:00:27:b7:fe:82 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.102/24 brd 192.168.1.255 scope global eth0
    inet6 fe80::a00:27ff:feb7:fe82/64 scope link 
       valid_lft forever preferred_lft forever
3: sit0: <NOARP> mtu 1480 qdisc noop 
    link/sit 0.0.0.0 brd 0.0.0.0

For example, this only listens on 192.168.1.102.

Add an IP address (works):
[root@localhost examples]# /usr/local/mmm/bin/check_ip 192.168.1.99 eth0
OK: IP has been address added

Try to add it again (exists):
[root@localhost examples]# /usr/local/mmm/bin/check_ip 192.168.1.99 eth0
OK: IP address presence check result is '1'

Add something that matches the pattern of what you added (broken):

[root@localhost examples]# /usr/local/mmm/bin/check_ip 192.168.1.9 eth0
OK: IP address presence check result is '1'

And try again to be safe (broken):
[root@localhost examples]# /usr/local/mmm/bin/check_ip 192.168.1.10 eth0
OK: IP address presence check result is '1'

Then unused pattern (works):
[root@localhost examples]# /usr/local/mmm/bin/check_ip 192.168.1.8 eth0
OK: IP has been address added

Original issue reported on code.google.com by toc...@gmail.com on 25 Mar 2009 at 5:15

GoogleCodeExporter commented 9 years ago
Suggested fix attached.

Original comment by toc...@gmail.com on 25 Mar 2009 at 5:24

Attachments:

GoogleCodeExporter commented 9 years ago
Hey Morgan,

I'll review your patch and let you know the outcome.

-- Ryan Lowe

Original comment by ryan.a.l...@gmail.com on 26 Apr 2009 at 6:49