Note: "permalinks" may not be as permanent as we would like,
direct links of old sources may well be a few messages off.
/ 2004-04-27 09:02:54 -0500 \ Todd Denniston: > Eugene Crosser wrote: > > > <SNIP> > > > > As to the local IP, when I need it I get it with an ugly sed/awk script > > run against the output of /sbin/ifconfig. Possibly a more elegant way > > exists... > > > yes I thought for a while that `hostname -a` and `hostname -i` could help me, > but I found that they depend on the way your /etc/hosts file is setup and did > not return any of the data that described eth0:0 and eth1, so it was less than > useful for me. ... for people that have /sbin/ifconfig around, and don't want to install or use /sbin/ip: I'm not yet sure how we will change CVS... maybe we just trust the admin, and do not check this at all? Lars Ellenberg diff -u -p -r1.1.2.22 drbdadm.h --- drbdadm.h 26 Apr 2004 08:36:29 -0000 1.1.2.22 +++ drbdadm.h 27 Apr 2004 14:31:18 -0000 @@ -16,6 +16,8 @@ /* for verify_ips(): make not verifyable ips fatal */ //#define INVALID_IP_IS_INVALID_CONF +#define USE_SBIN_IP 0 +#define USE_SBIN_IFCONFIG 1 struct d_globals { diff -u -p -r1.1.2.45 drbdadm_main.c --- drbdadm_main.c 26 Apr 2004 08:36:29 -0000 1.1.2.45 +++ drbdadm_main.c 27 Apr 2004 14:31:19 -0000 @@ -604,7 +604,7 @@ int m_shell_match(const char *subcmd, co #ifdef DEBUG ex = asprintf(&cmd, "[[ `%s` == %s ]]", subcmd, pattern); #else - ex = asprintf(&cmd, "[[ `%s` == %s ]] &>/dev/null", subcmd, pattern); + ex = asprintf(&cmd, "[[ `%s` == %s ]] >/dev/null", subcmd, pattern); #endif if (ex < 0) { perror("asprintf"); exit(E_thinko); } @@ -643,10 +643,19 @@ void verify_ips(struct d_resource* res) } my_ip = res->me->address; his_ip = res->peer->address; +#if USE_SBIN_IP ex = asprintf(&cmd, "/sbin/ip -o addr show scope global to %s", my_ip); if (ex < 0) { perror("asprintf"); exit(E_thinko); } ex = asprintf(&pat, "*inet\\ %s/*", my_ip); if (ex < 0) { perror("asprintf"); exit(E_thinko); } +#elif USE_SBIN_IFCONFIG + ex = asprintf(&cmd, "LANG='' /sbin/ifconfig | grep ' inet addr:%s '", my_ip); + if (ex < 0) { perror("asprintf"); exit(E_thinko); } + ex = asprintf(&pat, "*\\ inet\\ addr:%s\\ *", my_ip); + if (ex < 0) { perror("asprintf"); exit(E_thinko); } +#else + return; // cannot check ip. +#endif ex = m_shell_match(cmd, pat); free(cmd); cmd = NULL; free(pat); pat = NULL; @@ -664,6 +673,8 @@ void verify_ips(struct d_resource* res) free(e.key); return; } + +#if USE_SBIN_IP asprintf(&cmd, "/sbin/ip -o route get to %s", his_ip); if (ex < 0) { perror("asprintf"); exit(E_thinko); } asprintf(&pat, "%s\\ dev*src\\ %s\\ \\\\*", his_ip, my_ip); @@ -678,11 +689,14 @@ void verify_ips(struct d_resource* res) ep = hsearch(e, FIND); fprintf(stderr, "%s:%d: in resource %s:\n\tNo route from me (%s) to peer (%s).\n", config_file,(int) ep->data,res->name, my_ip, his_ip); -#ifdef INVALID_IP_IS_INVALID_CONF +# ifdef INVALID_IP_IS_INVALID_CONF config_valid = 0; -#endif +# endif return; } +#else + /* cannot check route to peer */ +#endif return; } diff -u -p -r1.54.2.30 drbdsetup.c --- drbdsetup.c 26 Apr 2004 08:36:29 -0000 1.54.2.30 +++ drbdsetup.c 27 Apr 2004 14:31:19 -0000 @@ -855,7 +855,7 @@ int cmd_invalidate(int drbd_fd,char** ar err=errno; perror("ioctl() failed"); if(err==EINPROGRESS) - fprintf(stderr,"Only in 'Connected' cstate possible."); + fprintf(stderr,"Only in 'Connected' cstate possible.\n"); return 20; } return 0; @@ -871,7 +871,7 @@ int cmd_invalidate_rem(int drbd_fd,char* err=errno; perror("ioctl() failed"); if(err==EINPROGRESS) - fprintf(stderr,"Only in 'Connected' cstate possible."); + fprintf(stderr,"Only in 'Connected' cstate possible.\n"); return 20; } return 0;