skb_dst is an inline helper with a WARN_ON(), so this is a bit more code than it looks like.
Unified · Split
| @@ -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 | ||
| 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 | |||
| 276 | void nft_meta_get_eval(const struct nft_expr *expr, | 290 | void 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_CLASSID | 335 | #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 | #endif | 340 | #endif |
| 331 | #ifdef CONFIG_NETWORK_SECMARK | 341 | #ifdef CONFIG_NETWORK_SECMARK |
| 332 | case NFT_META_SECMARK: | 342 | case NFT_META_SECMARK: |