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
273273 return prandom_u32_state(state);
274274 }
275275
276+#ifdef CONFIG_IP_ROUTE_CLASSID
277+static noinline bool
278+nft_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+
276290 void nft_meta_get_eval(const struct nft_expr *expr,
277291 struct nft_regs *regs,
278292 const struct nft_pktinfo *pkt)
@@ -319,14 +333,10 @@ void nft_meta_get_eval(const struct nft_expr *expr, · 40 unmodified lines
319333 goto err;
320334 break;
321335 #ifdef CONFIG_IP_ROUTE_CLASSID
322− case NFT_META_RTCLASSID: {
323− const struct dst_entry *dst = skb_dst(skb);
324−
325− if (dst == NULL)
336+ case NFT_META_RTCLASSID:
337+ if (!nft_meta_get_eval_rtclassid(skb, dest))
326338 goto err;
327− *dest = dst->tclassid;
328339 break;
329− }
330340 #endif
331341 #ifdef CONFIG_NETWORK_SECMARK
332342 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