@@ -119,6 +119,9 @@ static netdev_tx_t vrf_process_v6_outbound(struct sk_buff *skb,
119
119
skb_dst_drop (skb );
120
120
skb_dst_set (skb , dst );
121
121
122
+ /* strip the ethernet header added for pass through VRF device */
123
+ __skb_pull (skb , skb_network_offset (skb ));
124
+
122
125
ret = ip6_local_out (net , skb -> sk , skb );
123
126
if (unlikely (net_xmit_eval (ret )))
124
127
dev -> stats .tx_errors ++ ;
@@ -139,29 +142,6 @@ static netdev_tx_t vrf_process_v6_outbound(struct sk_buff *skb,
139
142
}
140
143
#endif
141
144
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
-
165
145
static netdev_tx_t vrf_process_v4_outbound (struct sk_buff * skb ,
166
146
struct net_device * vrf_dev )
167
147
{
@@ -176,10 +156,24 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
176
156
FLOWI_FLAG_SKIP_NH_OIF ,
177
157
.daddr = ip4h -> daddr ,
178
158
};
159
+ struct net * net = dev_net (vrf_dev );
160
+ struct rtable * rt ;
179
161
180
- if (vrf_send_v4_prep (skb , & fl4 , vrf_dev ))
162
+ rt = ip_route_output_flow (net , & fl4 , NULL );
163
+ if (IS_ERR (rt ))
181
164
goto err ;
182
165
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
+
183
177
if (!ip4h -> saddr ) {
184
178
ip4h -> saddr = inet_select_addr (skb_dst (skb )-> dev , 0 ,
185
179
RT_SCOPE_LINK );
@@ -200,9 +194,6 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
200
194
201
195
static netdev_tx_t is_ip_tx_frame (struct sk_buff * skb , struct net_device * dev )
202
196
{
203
- /* strip the ethernet header added for pass through VRF device */
204
- __skb_pull (skb , skb_network_offset (skb ));
205
-
206
197
switch (skb -> protocol ) {
207
198
case htons (ETH_P_IP ):
208
199
return vrf_process_v4_outbound (skb , dev );
0 commit comments