Skip to content

Commit 911a66f

Browse files
David Aherndavem330
authored andcommitted
net: vrf: Minor refactoring for local address patches
Move the stripping of the ethernet header from is_ip_tx_frame into the ipv4 and ipv6 outbound functions and collapse vrf_send_v4_prep into vrf_process_v4_outbound. Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c1e48af commit 911a66f

File tree

1 file changed

+18
-27
lines changed

1 file changed

+18
-27
lines changed

drivers/net/vrf.c

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ static netdev_tx_t vrf_process_v6_outbound(struct sk_buff *skb,
119119
skb_dst_drop(skb);
120120
skb_dst_set(skb, dst);
121121

122+
/* strip the ethernet header added for pass through VRF device */
123+
__skb_pull(skb, skb_network_offset(skb));
124+
122125
ret = ip6_local_out(net, skb->sk, skb);
123126
if (unlikely(net_xmit_eval(ret)))
124127
dev->stats.tx_errors++;
@@ -139,29 +142,6 @@ static netdev_tx_t vrf_process_v6_outbound(struct sk_buff *skb,
139142
}
140143
#endif
141144

142-
static int vrf_send_v4_prep(struct sk_buff *skb, struct flowi4 *fl4,
143-
struct net_device *vrf_dev)
144-
{
145-
struct rtable *rt;
146-
int err = 1;
147-
148-
rt = ip_route_output_flow(dev_net(vrf_dev), fl4, NULL);
149-
if (IS_ERR(rt))
150-
goto out;
151-
152-
/* TO-DO: what about broadcast ? */
153-
if (rt->rt_type != RTN_UNICAST && rt->rt_type != RTN_LOCAL) {
154-
ip_rt_put(rt);
155-
goto out;
156-
}
157-
158-
skb_dst_drop(skb);
159-
skb_dst_set(skb, &rt->dst);
160-
err = 0;
161-
out:
162-
return err;
163-
}
164-
165145
static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
166146
struct net_device *vrf_dev)
167147
{
@@ -176,10 +156,24 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
176156
FLOWI_FLAG_SKIP_NH_OIF,
177157
.daddr = ip4h->daddr,
178158
};
159+
struct net *net = dev_net(vrf_dev);
160+
struct rtable *rt;
179161

180-
if (vrf_send_v4_prep(skb, &fl4, vrf_dev))
162+
rt = ip_route_output_flow(net, &fl4, NULL);
163+
if (IS_ERR(rt))
181164
goto err;
182165

166+
if (rt->rt_type != RTN_UNICAST && rt->rt_type != RTN_LOCAL) {
167+
ip_rt_put(rt);
168+
goto err;
169+
}
170+
171+
skb_dst_drop(skb);
172+
skb_dst_set(skb, &rt->dst);
173+
174+
/* strip the ethernet header added for pass through VRF device */
175+
__skb_pull(skb, skb_network_offset(skb));
176+
183177
if (!ip4h->saddr) {
184178
ip4h->saddr = inet_select_addr(skb_dst(skb)->dev, 0,
185179
RT_SCOPE_LINK);
@@ -200,9 +194,6 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
200194

201195
static netdev_tx_t is_ip_tx_frame(struct sk_buff *skb, struct net_device *dev)
202196
{
203-
/* strip the ethernet header added for pass through VRF device */
204-
__skb_pull(skb, skb_network_offset(skb));
205-
206197
switch (skb->protocol) {
207198
case htons(ETH_P_IP):
208199
return vrf_process_v4_outbound(skb, dev);

0 commit comments

Comments
 (0)