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 | 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 | 290 | void nft_meta_get_eval(const struct nft_expr *expr, |
| 277 | 291 | struct nft_regs *regs, |
| 278 | 292 | const struct nft_pktinfo *pkt) |
| @@ -319,14 +333,10 @@ void nft_meta_get_eval(const struct nft_expr *expr, · 40 unmodified lines | ||
| 319 | 333 | goto err; |
| 320 | 334 | break; |
| 321 | 335 | #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)) | |
| 326 | 338 | goto err; |
| 327 | − *dest = dst->tclassid; | |
| 328 | 339 | break; |
| 329 | − } | |
| 330 | 340 | #endif |
| 331 | 341 | #ifdef CONFIG_NETWORK_SECMARK |
| 332 | 342 | case NFT_META_SECMARK: |