Skip to content

Commit 57c4bf8

Browse files
ebiedermdavem330
authored andcommitted
ipvlan: Cache net in ipvlan_process_v4_outbound and ipvlan_process_v6_outbound
Compute net once in ipvlan_process_v4_outbound and ipvlan_process_v6_outbound and store it in a variable so that net does not need to be recomputed next time it is used. Signed-off-by: "Eric W. Biederman" <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a7093fe commit 57c4bf8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/net/ipvlan/ipvlan_core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb)
344344
{
345345
const struct iphdr *ip4h = ip_hdr(skb);
346346
struct net_device *dev = skb->dev;
347+
struct net *net = dev_net(dev);
347348
struct rtable *rt;
348349
int err, ret = NET_XMIT_DROP;
349350
struct flowi4 fl4 = {
@@ -354,7 +355,7 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb)
354355
.saddr = ip4h->saddr,
355356
};
356357

357-
rt = ip_route_output_flow(dev_net(dev), &fl4, NULL);
358+
rt = ip_route_output_flow(net, &fl4, NULL);
358359
if (IS_ERR(rt))
359360
goto err;
360361

@@ -381,6 +382,7 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb)
381382
{
382383
const struct ipv6hdr *ip6h = ipv6_hdr(skb);
383384
struct net_device *dev = skb->dev;
385+
struct net *net = dev_net(dev);
384386
struct dst_entry *dst;
385387
int err, ret = NET_XMIT_DROP;
386388
struct flowi6 fl6 = {
@@ -393,7 +395,7 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb)
393395
.flowi6_proto = ip6h->nexthdr,
394396
};
395397

396-
dst = ip6_route_output(dev_net(dev), NULL, &fl6);
398+
dst = ip6_route_output(net, NULL, &fl6);
397399
if (dst->error) {
398400
ret = dst->error;
399401
dst_release(dst);

0 commit comments

Comments
 (0)