Skip to content

Commit 82e2e78

Browse files
Stefan Raspldavem330
authored andcommitted
qeth: Fix invalid router settings handling
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>
1 parent 82f77cf commit 82e2e78

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎drivers/s390/net/qeth_l3_main.c‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ static int qeth_l3_send_setrouting(struct qeth_card *card,
623623
return rc;
624624
}
625625

626-
static void qeth_l3_correct_routing_type(struct qeth_card *card,
626+
static int qeth_l3_correct_routing_type(struct qeth_card *card,
627627
enum qeth_routing_types *type, enum qeth_prot_versions prot)
628628
{
629629
if (card->info.type == QETH_CARD_TYPE_IQD) {
@@ -632,7 +632,7 @@ static void qeth_l3_correct_routing_type(struct qeth_card *card,
632632
case PRIMARY_CONNECTOR:
633633
case SECONDARY_CONNECTOR:
634634
case MULTICAST_ROUTER:
635-
return;
635+
return 0;
636636
default:
637637
goto out_inval;
638638
}
@@ -641,17 +641,18 @@ static void qeth_l3_correct_routing_type(struct qeth_card *card,
641641
case NO_ROUTER:
642642
case PRIMARY_ROUTER:
643643
case SECONDARY_ROUTER:
644-
return;
644+
return 0;
645645
case MULTICAST_ROUTER:
646646
if (qeth_is_ipafunc_supported(card, prot,
647647
IPA_OSA_MC_ROUTER))
648-
return;
648+
return 0;
649649
default:
650650
goto out_inval;
651651
}
652652
}
653653
out_inval:
654654
*type = NO_ROUTER;
655+
return -EINVAL;
655656
}
656657

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

661662
QETH_CARD_TEXT(card, 3, "setrtg4");
662663

663-
qeth_l3_correct_routing_type(card, &card->options.route4.type,
664+
rc = qeth_l3_correct_routing_type(card, &card->options.route4.type,
664665
QETH_PROT_IPV4);
666+
if (rc)
667+
return rc;
665668

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

684687
if (!qeth_is_supported(card, IPA_IPV6))
685688
return 0;
686-
qeth_l3_correct_routing_type(card, &card->options.route6.type,
689+
rc = qeth_l3_correct_routing_type(card, &card->options.route6.type,
687690
QETH_PROT_IPV6);
691+
if (rc)
692+
return rc;
688693

689694
rc = qeth_l3_send_setrouting(card, card->options.route6.type,
690695
QETH_PROT_IPV6);

‎drivers/s390/net/qeth_l3_sys.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ static ssize_t qeth_l3_dev_route_store(struct qeth_card *card,
8787
rc = qeth_l3_setrouting_v6(card);
8888
}
8989
out:
90+
if (rc)
91+
route->type = old_route_type;
9092
mutex_unlock(&card->conf_mutex);
9193
return rc ? rc : count;
9294
}

0 commit comments

Comments
 (0)