On Tue, Jun 11, 2019 at 08:09:12AM -0400, Stephen Suryaputra wrote:
[...]
> diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c
> index a940c9fd9045..4155a32fade7 100644
> --- a/net/netfilter/nft_exthdr.c
> +++ b/net/netfilter/nft_exthdr.c
[...]
> +static int ipv4_find_option(struct net *net, struct sk_buff *skb,
> +                         unsigned int *offset, int target,
> +                         unsigned short *fragoff, int *flags)
> +{
[...]
> +     switch (target) {
> +     case IPOPT_SSRR:
> +     case IPOPT_LSRR:
[...]
> +     case IPOPT_RR:
[...]
> +     case IPOPT_RA:
[...]
> +     default:
> +             /* Either not supported or not a specific search, treated as
> +              * found
> +              */
> +             found = true;
> +             if (target >= 0) {
> +                     target = -EOPNOTSUPP;
> +                     break;
> +             }

Rules with this options will load fine:

ip option eol type 1
ip option noop type 1
ip option sec type 1
ip option timestamp type 1
ip option rr type 1
ip option sid type 1

However, they will not ever match I think.

found is set to true, but target is set to EOPNOTSUPP, then...

[...]
> +static void nft_exthdr_ipv4_eval(const struct nft_expr *expr,
> +                              struct nft_regs *regs,
> +                              const struct nft_pktinfo *pkt)
> +{
> +     struct nft_exthdr *priv = nft_expr_priv(expr);
> +     u32 *dest = &regs->data[priv->dreg];
> +     struct sk_buff *skb = pkt->skb;
> +     unsigned int offset;
> +     int err;
> +
> +     if (skb->protocol != htons(ETH_P_IP))
> +             goto err;
> +
> +     err = ipv4_find_option(nft_net(pkt), skb, &offset, priv->type, NULL, 
> NULL);

... ipv4_find_option() returns -EOPNOTSUPP which says header does
not exist.

> +     if (priv->flags & NFT_EXTHDR_F_PRESENT) {
> +             *dest = (err >= 0);
> +             return;
> +     } else if (err < 0) {
> +             goto err;
> +     }

Reply via email to