s390/qeth: add wrapper for IP table access
Extract a little helper, so that high-level callers can manipulate the IP table without worrying about the locking. This will make it easier to convert the code to a different locking primitive later on. Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
5c0aebc6db
commit
05a1785134
|
@ -268,6 +268,18 @@ static int qeth_l3_add_ip(struct qeth_card *card, struct qeth_ipaddr *tmp_addr)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int qeth_l3_modify_ip(struct qeth_card *card, struct qeth_ipaddr *addr,
|
||||||
|
bool add)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
spin_lock_bh(&card->ip_lock);
|
||||||
|
rc = add ? qeth_l3_add_ip(card, addr) : qeth_l3_delete_ip(card, addr);
|
||||||
|
spin_unlock_bh(&card->ip_lock);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
static void qeth_l3_drain_rx_mode_cache(struct qeth_card *card)
|
static void qeth_l3_drain_rx_mode_cache(struct qeth_card *card)
|
||||||
{
|
{
|
||||||
struct qeth_ipaddr *addr;
|
struct qeth_ipaddr *addr;
|
||||||
|
@ -636,7 +648,6 @@ int qeth_l3_modify_rxip_vipa(struct qeth_card *card, bool add, const u8 *ip,
|
||||||
enum qeth_prot_versions proto)
|
enum qeth_prot_versions proto)
|
||||||
{
|
{
|
||||||
struct qeth_ipaddr addr;
|
struct qeth_ipaddr addr;
|
||||||
int rc;
|
|
||||||
|
|
||||||
qeth_l3_init_ipaddr(&addr, type, proto);
|
qeth_l3_init_ipaddr(&addr, type, proto);
|
||||||
if (proto == QETH_PROT_IPV4)
|
if (proto == QETH_PROT_IPV4)
|
||||||
|
@ -644,16 +655,13 @@ int qeth_l3_modify_rxip_vipa(struct qeth_card *card, bool add, const u8 *ip,
|
||||||
else
|
else
|
||||||
memcpy(&addr.u.a6.addr, ip, 16);
|
memcpy(&addr.u.a6.addr, ip, 16);
|
||||||
|
|
||||||
spin_lock_bh(&card->ip_lock);
|
return qeth_l3_modify_ip(card, &addr, add);
|
||||||
rc = add ? qeth_l3_add_ip(card, &addr) : qeth_l3_delete_ip(card, &addr);
|
|
||||||
spin_unlock_bh(&card->ip_lock);
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int qeth_l3_modify_hsuid(struct qeth_card *card, bool add)
|
int qeth_l3_modify_hsuid(struct qeth_card *card, bool add)
|
||||||
{
|
{
|
||||||
struct qeth_ipaddr addr;
|
struct qeth_ipaddr addr;
|
||||||
int rc, i;
|
unsigned int i;
|
||||||
|
|
||||||
qeth_l3_init_ipaddr(&addr, QETH_IP_TYPE_NORMAL, QETH_PROT_IPV6);
|
qeth_l3_init_ipaddr(&addr, QETH_IP_TYPE_NORMAL, QETH_PROT_IPV6);
|
||||||
addr.u.a6.addr.s6_addr[0] = 0xfe;
|
addr.u.a6.addr.s6_addr[0] = 0xfe;
|
||||||
|
@ -661,10 +669,7 @@ int qeth_l3_modify_hsuid(struct qeth_card *card, bool add)
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
addr.u.a6.addr.s6_addr[8+i] = card->options.hsuid[i];
|
addr.u.a6.addr.s6_addr[8+i] = card->options.hsuid[i];
|
||||||
|
|
||||||
spin_lock_bh(&card->ip_lock);
|
return qeth_l3_modify_ip(card, &addr, add);
|
||||||
rc = add ? qeth_l3_add_ip(card, &addr) : qeth_l3_delete_ip(card, &addr);
|
|
||||||
spin_unlock_bh(&card->ip_lock);
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qeth_l3_register_addr_entry(struct qeth_card *card,
|
static int qeth_l3_register_addr_entry(struct qeth_card *card,
|
||||||
|
@ -2527,14 +2532,10 @@ static int qeth_l3_handle_ip_event(struct qeth_card *card,
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case NETDEV_UP:
|
case NETDEV_UP:
|
||||||
spin_lock_bh(&card->ip_lock);
|
qeth_l3_modify_ip(card, addr, true);
|
||||||
qeth_l3_add_ip(card, addr);
|
|
||||||
spin_unlock_bh(&card->ip_lock);
|
|
||||||
return NOTIFY_OK;
|
return NOTIFY_OK;
|
||||||
case NETDEV_DOWN:
|
case NETDEV_DOWN:
|
||||||
spin_lock_bh(&card->ip_lock);
|
qeth_l3_modify_ip(card, addr, false);
|
||||||
qeth_l3_delete_ip(card, addr);
|
|
||||||
spin_unlock_bh(&card->ip_lock);
|
|
||||||
return NOTIFY_OK;
|
return NOTIFY_OK;
|
||||||
default:
|
default:
|
||||||
return NOTIFY_DONE;
|
return NOTIFY_DONE;
|
||||||
|
|
Loading…
Reference in New Issue