History

netfilter: nft_meta: place rtclassid handling in a helper

skb_dst is an inline helper with a WARN_ON(), so this is a bit more code than it looks like.

Florian Westphal committed 6 years ago

Commit 01a0fc81 parent 6b2faee1 file · +16 −6Browse files

Unified · Split

net/netfilter/nft_meta.c+16−6
@@ -273,6 +273,20 @@ static noinline u32 nft_prandom_u32(void) · 272 unmodified lines
273 return prandom_u32_state(state);273 return prandom_u32_state(state);
274}274}
275 275
276#ifdef CONFIG_IP_ROUTE_CLASSID
277static noinline bool
278nft_meta_get_eval_rtclassid(const struct sk_buff *skb, u32 *dest)
279{
280 const struct dst_entry *dst = skb_dst(skb);
281
282 if (!dst)
283 return false;
284
285 *dest = dst->tclassid;
286 return true;
287}
288#endif
289
276void nft_meta_get_eval(const struct nft_expr *expr,290void nft_meta_get_eval(const struct nft_expr *expr,
277 struct nft_regs *regs,291 struct nft_regs *regs,
278 const struct nft_pktinfo *pkt)292 const struct nft_pktinfo *pkt)
@@ -319,14 +333,10 @@ void nft_meta_get_eval(const struct nft_expr *expr, · 40 unmodified lines
319 goto err;333 goto err;
320 break;334 break;
321#ifdef CONFIG_IP_ROUTE_CLASSID335#ifdef CONFIG_IP_ROUTE_CLASSID
322 case NFT_META_RTCLASSID: {336 case NFT_META_RTCLASSID:
323 const struct dst_entry *dst = skb_dst(skb);337 if (!nft_meta_get_eval_rtclassid(skb, dest))
324
325 if (dst == NULL)
326 goto err;338 goto err;
327 *dest = dst->tclassid;
328 break;339 break;
329 }
330#endif340#endif
331#ifdef CONFIG_NETWORK_SECMARK341#ifdef CONFIG_NETWORK_SECMARK
332 case NFT_META_SECMARK:342 case NFT_META_SECMARK:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t