[U-Boot] [PATCH v2 05/21] net: Encapsulate CDP packet identification

Simon Glass sjg at chromium.org
Sat Apr 21 05:01:21 CEST 2012


Hi Joe,

On Tue, Mar 27, 2012 at 4:42 PM, Joe Hershberger <joe.hershberger at ni.com> wrote:
> Checking for CDP packets should be encapsulated, not copied code.
>
> Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
> Cc: Joe Hershberger <joe.hershberger at gmail.com>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Mike Frysinger <vapier at gentoo.org>
> ---
> Changes for v2:
>   - Split from patch "Move CDP out of net.c"
>   - Changed to static inline
>
>  arch/powerpc/cpu/mpc8xx/fec.c |    2 +-
>  include/net.h                 |    7 +++++--
>  net/net.c                     |    2 +-
>  3 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/cpu/mpc8xx/fec.c b/arch/powerpc/cpu/mpc8xx/fec.c
> index f2a2c3a..0bc1e5d 100644
> --- a/arch/powerpc/cpu/mpc8xx/fec.c
> +++ b/arch/powerpc/cpu/mpc8xx/fec.c
> @@ -274,7 +274,7 @@ static int fec_recv (struct eth_device *dev)
>  #if defined(CONFIG_CMD_CDP)
>                        if ((rx[0] & 1) != 0
>                            && memcmp ((uchar *) rx, NetBcastAddr, 6) != 0
> -                           && memcmp ((uchar *) rx, NetCDPAddr, 6) != 0)
> +                           && !is_cdp_packet((uchar *)rx))
>                                rx = NULL;
>  #endif
>                        /*
> diff --git a/include/net.h b/include/net.h
> index 54f05bb..7bd8043 100644
> --- a/include/net.h
> +++ b/include/net.h
> @@ -355,8 +355,6 @@ extern uchar                NetEtherNullAddr[6];
>  extern ushort          NetOurVLAN;             /* Our VLAN */
>  extern ushort          NetOurNativeVLAN;       /* Our Native VLAN */
>
> -extern const uchar     NetCDPAddr[6];          /* Ethernet CDP address */
> -
>  extern int             NetState;               /* Network loop state */
>  #define NETLOOP_CONTINUE       1
>  #define NETLOOP_RESTART                2
> @@ -386,6 +384,11 @@ extern IPaddr_t    NetPingIP;                      /* the ip address to ping */
>  /* when CDP completes these hold the return values */
>  extern ushort CDPNativeVLAN;           /* CDP returned native VLAN */
>  extern ushort CDPApplianceVLAN;                /* CDP returned appliance VLAN */

blank line, function comment

> +static inline int is_cdp_packet(const uchar *et_addr)
> +{
> +       extern const uchar NetCDPAddr[6];

blank line?

> +       return memcmp(et_addr, NetCDPAddr, 6) == 0;
> +}
>  #endif
>
>  #if defined(CONFIG_CMD_SNTP)
> diff --git a/net/net.c b/net/net.c
> index b5b072a..7fdd71f 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -1101,7 +1101,7 @@ NetReceive(uchar *inpkt, int len)
>
>  #if defined(CONFIG_CMD_CDP)
>        /* keep track if packet is CDP */
> -       iscdp = memcmp(et->et_dest, NetCDPAddr, 6) == 0;
> +       iscdp = is_cdp_packet(et->et_dest);
>  #endif
>
>        myvlanid = ntohs(NetOurVLAN);
> --
> 1.6.0.2
>

Regards,
Simon


More information about the U-Boot mailing list