mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-09 14:50:19 +00:00
s390/qeth: remove open-coded inet_make_mask()
Use inet_make_mask() to replace some complicated bit-fiddling. Also use the right data types to replace some raw memcpy calls with proper assignments. Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
2390166a6b
commit
490df97142
@ -338,14 +338,14 @@ enum qeth_card_info_port_speed {
|
|||||||
|
|
||||||
/* (SET)DELIP(M) IPA stuff ***************************************************/
|
/* (SET)DELIP(M) IPA stuff ***************************************************/
|
||||||
struct qeth_ipacmd_setdelip4 {
|
struct qeth_ipacmd_setdelip4 {
|
||||||
__u8 ip_addr[4];
|
__be32 addr;
|
||||||
__u8 mask[4];
|
__be32 mask;
|
||||||
__u32 flags;
|
__u32 flags;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
struct qeth_ipacmd_setdelip6 {
|
struct qeth_ipacmd_setdelip6 {
|
||||||
__u8 ip_addr[16];
|
struct in6_addr addr;
|
||||||
__u8 mask[16];
|
struct in6_addr prefix;
|
||||||
__u32 flags;
|
__u32 flags;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ struct qeth_ipaddr {
|
|||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
__be32 addr;
|
__be32 addr;
|
||||||
unsigned int mask;
|
__be32 mask;
|
||||||
} a4;
|
} a4;
|
||||||
struct {
|
struct {
|
||||||
struct in6_addr addr;
|
struct in6_addr addr;
|
||||||
|
@ -369,17 +369,16 @@ static int qeth_l3_send_setdelmc(struct qeth_card *card,
|
|||||||
return qeth_send_ipa_cmd(card, iob, qeth_l3_setdelip_cb, NULL);
|
return qeth_send_ipa_cmd(card, iob, qeth_l3_setdelip_cb, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qeth_l3_fill_netmask(u8 *netmask, unsigned int len)
|
static void qeth_l3_set_ipv6_prefix(struct in6_addr *prefix, unsigned int len)
|
||||||
{
|
{
|
||||||
int i, j;
|
unsigned int i = 0;
|
||||||
for (i = 0; i < 16; i++) {
|
|
||||||
j = (len) - (i * 8);
|
while (len && i < 4) {
|
||||||
if (j >= 8)
|
int mask_len = min_t(int, len, 32);
|
||||||
netmask[i] = 0xff;
|
|
||||||
else if (j > 0)
|
prefix->s6_addr32[i] = inet_make_mask(mask_len);
|
||||||
netmask[i] = (u8)(0xFF00 >> j);
|
len -= mask_len;
|
||||||
else
|
i++;
|
||||||
netmask[i] = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +401,6 @@ static int qeth_l3_send_setdelip(struct qeth_card *card,
|
|||||||
{
|
{
|
||||||
struct qeth_cmd_buffer *iob;
|
struct qeth_cmd_buffer *iob;
|
||||||
struct qeth_ipa_cmd *cmd;
|
struct qeth_ipa_cmd *cmd;
|
||||||
__u8 netmask[16];
|
|
||||||
u32 flags;
|
u32 flags;
|
||||||
|
|
||||||
QETH_CARD_TEXT(card, 4, "setdelip");
|
QETH_CARD_TEXT(card, 4, "setdelip");
|
||||||
@ -417,15 +415,13 @@ static int qeth_l3_send_setdelip(struct qeth_card *card,
|
|||||||
QETH_CARD_TEXT_(card, 4, "flags%02X", flags);
|
QETH_CARD_TEXT_(card, 4, "flags%02X", flags);
|
||||||
|
|
||||||
if (addr->proto == QETH_PROT_IPV6) {
|
if (addr->proto == QETH_PROT_IPV6) {
|
||||||
memcpy(cmd->data.setdelip6.ip_addr, &addr->u.a6.addr,
|
cmd->data.setdelip6.addr = addr->u.a6.addr;
|
||||||
sizeof(struct in6_addr));
|
qeth_l3_set_ipv6_prefix(&cmd->data.setdelip6.prefix,
|
||||||
qeth_l3_fill_netmask(netmask, addr->u.a6.pfxlen);
|
addr->u.a6.pfxlen);
|
||||||
memcpy(cmd->data.setdelip6.mask, netmask,
|
|
||||||
sizeof(struct in6_addr));
|
|
||||||
cmd->data.setdelip6.flags = flags;
|
cmd->data.setdelip6.flags = flags;
|
||||||
} else {
|
} else {
|
||||||
memcpy(cmd->data.setdelip4.ip_addr, &addr->u.a4.addr, 4);
|
cmd->data.setdelip4.addr = addr->u.a4.addr;
|
||||||
memcpy(cmd->data.setdelip4.mask, &addr->u.a4.mask, 4);
|
cmd->data.setdelip4.mask = addr->u.a4.mask;
|
||||||
cmd->data.setdelip4.flags = flags;
|
cmd->data.setdelip4.flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2436,7 +2432,7 @@ static int qeth_l3_ip_event(struct notifier_block *this,
|
|||||||
|
|
||||||
qeth_l3_init_ipaddr(&addr, QETH_IP_TYPE_NORMAL, QETH_PROT_IPV4);
|
qeth_l3_init_ipaddr(&addr, QETH_IP_TYPE_NORMAL, QETH_PROT_IPV4);
|
||||||
addr.u.a4.addr = ifa->ifa_address;
|
addr.u.a4.addr = ifa->ifa_address;
|
||||||
addr.u.a4.mask = be32_to_cpu(ifa->ifa_mask);
|
addr.u.a4.mask = ifa->ifa_mask;
|
||||||
|
|
||||||
return qeth_l3_handle_ip_event(card, &addr, event);
|
return qeth_l3_handle_ip_event(card, &addr, event);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user