Skip to content

Commit

Permalink
deal with funny SIOCSETMPWCFG ioctl, carefully
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowman committed May 31, 2016
1 parent 89c12e6 commit 4ac0b8b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions commands.c
Expand Up @@ -678,6 +678,8 @@ interface(int argc, char **argv, char *modhvar)
bridge = 0;
}

imr_init(ifname);

if (modhvar) {
/* direct rcfile -i or -c initialization */
char *argp;
Expand Down
1 change: 1 addition & 0 deletions externs.h
Expand Up @@ -372,6 +372,7 @@ int parse_ipv6(char *, struct in6_addr *);
#define ROUNDMBPS(bps) ((float)bps == ((bps / 1000 / 1000) * 1000 * 1000))
#define ROUNDKBPS(bps) ((float)bps == ((bps / 1000) * 1000))
#define ROUNDKBYTES(bytes) ((float)bytes == ((bytes / 1024) * 1024))
void imr_init(char *);
int is_valid_ifname(char *);
int show_int(int, char **);
int get_rdomain(int, char *);
Expand Down
17 changes: 13 additions & 4 deletions if.c
Expand Up @@ -55,6 +55,7 @@ void printifhwfeatures(int, char *);
void show_vnet_parent(int, char *);

static struct ifmpwreq imrsave;
static char imrif[IFNAMSIZ];

static const struct {
char *name;
Expand Down Expand Up @@ -86,6 +87,14 @@ static const struct {
{ "Unspecified", IFT_OTHER },
};

void imr_init(char *ifname)
{
if (strcmp(ifname, imrif) == 0)
return;
strlcpy (imrif, ifname, IFNAMSIZ);
memset (&imrsave, 0, sizeof(imrsave));
}

int
show_int(int argc, char **argv)
{
Expand Down Expand Up @@ -1317,8 +1326,8 @@ intmpw(char *ifname, int ifs, int argc, char **argv)
imrsave.imr_rshim.shim_label == 0) {
if (imr.imr_lshim.shim_label == 0 ||
imr.imr_rshim.shim_label == 0) {
printf("%% mpw local / remote label not specified\n");
/*return 0;*/
/*printf("%% mpw local / remote label not specified\n");*/
return 0;
}
imrsave.imr_lshim.shim_label = imr.imr_lshim.shim_label;
imrsave.imr_rshim.shim_label = imr.imr_rshim.shim_label;
Expand All @@ -1328,8 +1337,8 @@ intmpw(char *ifname, int ifs, int argc, char **argv)
sinn = (struct sockaddr_in *) &imr.imr_nexthop;
if (sin->sin_addr.s_addr == 0) {
if (sinn->sin_addr.s_addr == 0) {
printf("%% mpw neighbor address not specified\n");
/*return 0;*/
/*printf("%% mpw neighbor address not specified\n");*/
return 0;
}

sin->sin_family = sinn->sin_family;
Expand Down

0 comments on commit 4ac0b8b

Please sign in to comment.