ok gkoehler@ with one comment change, see below.

On Sat, 21 Nov 2020 15:36:58 -0800
Greg Steuck <gne...@openbsd.org> wrote:

> diff --git sys/net/if_gre.c sys/net/if_gre.c
> index cb5beeaad62..deacad9c755 100644
> --- sys/net/if_gre.c
> +++ sys/net/if_gre.c
> @@ -1109,7 +1109,7 @@ gre_input_key(struct mbuf **mp, int *offp, int type, 
> int af, uint8_t otos,
>               if (n == NULL)
>                       goto decline;
>               if (n->m_data[off] >> 4 != IPVERSION)
> -                     hlen += sizeof(gre_wccp);
> +                     hlen += 4;  /* four-octet GRE header */
>  
>               /* FALLTHROUGH */
>       }

I want the comment to be, "four-octet Redirect header".  This is my
best guess after I glanced at section 4.12.1 of
https://tools.ietf.org/html/draft-wilson-wrec-wccp-v2-00

The Redirect header would be after the GRE header; the sizeof(*gh) in
"hlen = iphlen + sizeof(*gh);" was the GRE header.  I agree that using
sizeof(gre_wccp) is wrong, because that's the size of the
sysctl net.inet.gre.wccp, not the size of any header.

I don't have any way to test the wccp code.  --George

> @@ -4229,31 +4229,22 @@ drop:
>       return (NULL);
>  }
>  
> +const struct sysctl_bounded_args gre_vars[] = {
> +     { GRECTL_ALLOW, &gre_allow, 0, 1 },
> +     { GRECTL_WCCP, &gre_wccp, 0, 1 },
> +};
> +
>  int
>  gre_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
>      size_t newlen)
>  {
>       int error;
>  
> -     /* All sysctl names at this level are terminal. */
> -     if (namelen != 1)
> -             return (ENOTDIR);
> -
> -     switch (name[0]) {
> -     case GRECTL_ALLOW:
> -             NET_LOCK();
> -             error = sysctl_int(oldp, oldlenp, newp, newlen, &gre_allow);
> -             NET_UNLOCK();
> -             return (error);
> -     case GRECTL_WCCP:
> -             NET_LOCK();
> -             error = sysctl_int(oldp, oldlenp, newp, newlen, &gre_wccp);
> -             NET_UNLOCK();
> -             return (error);
> -     default:
> -             return (ENOPROTOOPT);
> -     }
> -     /* NOTREACHED */
> +     NET_LOCK();
> +     error = sysctl_bounded_arr(gre_vars, nitems(gre_vars), name,
> +         namelen, oldp, oldlenp, newp, newlen);
> +     NET_UNLOCK();
> +     return error;
>  }
>  
>  static inline int
> -- 
> 2.29.2
> 


-- 
George Koehler <kern...@gmail.com>

Reply via email to