Skip to content

Commit 51e9ba4

Browse files
q2venkuba-moo
authored andcommitted
arp: Remove a nest in arp_req_get().
This is a prep patch to make the following changes tidy. No functional change intended. Signed-off-by: Kuniyuki Iwashima <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f869613 commit 51e9ba4

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

net/ipv4/arp.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,23 +1138,28 @@ static int arp_req_get(struct arpreq *r, struct net_device *dev)
11381138
{
11391139
__be32 ip = ((struct sockaddr_in *) &r->arp_pa)->sin_addr.s_addr;
11401140
struct neighbour *neigh;
1141-
int err = -ENXIO;
11421141

11431142
neigh = neigh_lookup(&arp_tbl, &ip, dev);
1144-
if (neigh) {
1145-
if (!(READ_ONCE(neigh->nud_state) & NUD_NOARP)) {
1146-
read_lock_bh(&neigh->lock);
1147-
memcpy(r->arp_ha.sa_data, neigh->ha,
1148-
min(dev->addr_len, sizeof(r->arp_ha.sa_data_min)));
1149-
r->arp_flags = arp_state_to_flags(neigh);
1150-
read_unlock_bh(&neigh->lock);
1151-
r->arp_ha.sa_family = dev->type;
1152-
strscpy(r->arp_dev, dev->name, sizeof(r->arp_dev));
1153-
err = 0;
1154-
}
1143+
if (!neigh)
1144+
return -ENXIO;
1145+
1146+
if (READ_ONCE(neigh->nud_state) & NUD_NOARP) {
11551147
neigh_release(neigh);
1148+
return -ENXIO;
11561149
}
1157-
return err;
1150+
1151+
read_lock_bh(&neigh->lock);
1152+
memcpy(r->arp_ha.sa_data, neigh->ha,
1153+
min(dev->addr_len, sizeof(r->arp_ha.sa_data_min)));
1154+
r->arp_flags = arp_state_to_flags(neigh);
1155+
read_unlock_bh(&neigh->lock);
1156+
1157+
neigh_release(neigh);
1158+
1159+
r->arp_ha.sa_family = dev->type;
1160+
strscpy(r->arp_dev, dev->name, sizeof(r->arp_dev));
1161+
1162+
return 0;
11581163
}
11591164

11601165
int arp_invalidate(struct net_device *dev, __be32 ip, bool force)

0 commit comments

Comments
 (0)