Skip to content

Commit

Permalink
qeth: Fix invalid router settings handling
Browse files Browse the repository at this point in the history
Give a bad return code when specifying a router setting that is either
invalid or not support on the respective device type. In addition, fall back
the previous setting instead of silently switching back to 'no routing'.

Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
Signed-off-by: Frank Blaschka <blaschka@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Stefan Raspl authored and davem330 committed Mar 19, 2013
1 parent 82f77cf commit 82e2e78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 11 additions & 6 deletions drivers/s390/net/qeth_l3_main.c
Expand Up @@ -623,7 +623,7 @@ static int qeth_l3_send_setrouting(struct qeth_card *card,
return rc;
}

static void qeth_l3_correct_routing_type(struct qeth_card *card,
static int qeth_l3_correct_routing_type(struct qeth_card *card,
enum qeth_routing_types *type, enum qeth_prot_versions prot)
{
if (card->info.type == QETH_CARD_TYPE_IQD) {
Expand All @@ -632,7 +632,7 @@ static void qeth_l3_correct_routing_type(struct qeth_card *card,
case PRIMARY_CONNECTOR:
case SECONDARY_CONNECTOR:
case MULTICAST_ROUTER:
return;
return 0;
default:
goto out_inval;
}
Expand All @@ -641,17 +641,18 @@ static void qeth_l3_correct_routing_type(struct qeth_card *card,
case NO_ROUTER:
case PRIMARY_ROUTER:
case SECONDARY_ROUTER:
return;
return 0;
case MULTICAST_ROUTER:
if (qeth_is_ipafunc_supported(card, prot,
IPA_OSA_MC_ROUTER))
return;
return 0;
default:
goto out_inval;
}
}
out_inval:
*type = NO_ROUTER;
return -EINVAL;
}

int qeth_l3_setrouting_v4(struct qeth_card *card)
Expand All @@ -660,8 +661,10 @@ int qeth_l3_setrouting_v4(struct qeth_card *card)

QETH_CARD_TEXT(card, 3, "setrtg4");

qeth_l3_correct_routing_type(card, &card->options.route4.type,
rc = qeth_l3_correct_routing_type(card, &card->options.route4.type,
QETH_PROT_IPV4);
if (rc)
return rc;

rc = qeth_l3_send_setrouting(card, card->options.route4.type,
QETH_PROT_IPV4);
Expand All @@ -683,8 +686,10 @@ int qeth_l3_setrouting_v6(struct qeth_card *card)

if (!qeth_is_supported(card, IPA_IPV6))
return 0;
qeth_l3_correct_routing_type(card, &card->options.route6.type,
rc = qeth_l3_correct_routing_type(card, &card->options.route6.type,
QETH_PROT_IPV6);
if (rc)
return rc;

rc = qeth_l3_send_setrouting(card, card->options.route6.type,
QETH_PROT_IPV6);
Expand Down
2 changes: 2 additions & 0 deletions drivers/s390/net/qeth_l3_sys.c
Expand Up @@ -87,6 +87,8 @@ static ssize_t qeth_l3_dev_route_store(struct qeth_card *card,
rc = qeth_l3_setrouting_v6(card);
}
out:
if (rc)
route->type = old_route_type;
mutex_unlock(&card->conf_mutex);
return rc ? rc : count;
}
Expand Down

0 comments on commit 82e2e78

Please sign in to comment.