>
>
> > From b6b73ad37d9ca8907feff218b11325fa9456b3eb Mon Sep 17 00:00:00 2001
> > From: Magnus Armholt <magnus.armh...@fi.abb.com>
> > Date: Wed, 29 Jun 2022 10:00:54 +0300
> > Subject: [PATCH] Strip PRP trailer
> >
> > Strip the IEC62439-3 PRP trailer if it is present.
> > The implementation is very pedantic about
> > trailing bytes and will indicate bad message if the
> > PRP trailer bytes are present when parsing the PTP message.
>

Could you explain why we need this?
Why do we need the "*Parallel Redundancy Protocol* (*PRP*)"?
What are your user cases that use the PRP?

Please send the patch with

git send-email

https://git-scm.com/docs/git-send-email
With your proper

git format-patch

Erez

>
> > Signed-off-by: Magnus Armholt <magnus.armh...@fi.abb.com>
> > ---
> >  raw.c | 24 ++++++++++++++++++++++++
> >  1 file changed, 24 insertions(+)
> >
> > diff --git a/raw.c b/raw.c
> > index ce64684..fb23a1f 100644
> > --- a/raw.c
> > +++ b/raw.c
> > @@ -65,6 +65,8 @@ struct raw {
> >  #define N_RAW_FILTER    12
> >  #define RAW_FILTER_TEST 9
> >
> > +#define PRP_TRAILER_LEN 6
> > +
> >  static struct sock_filter raw_filter[N_RAW_FILTER] = {
> >   {OP_LDH,  0, 0, OFF_ETYPE   },
> >   {OP_JEQ,  0, 4, ETH_P_8021Q          }, /*f goto non-vlan block*/
> > @@ -206,6 +208,25 @@ static void addr_to_mac(void *mac, struct address
> *addr)
> >   memcpy(mac, &addr->sll.sll_addr, MAC_LEN);
> >  }
> >
> > +static int has_prp_trailer(unsigned char *ptr, int cnt)
> > +{
> > + if (cnt < PRP_TRAILER_LEN)
> > + return -1;
> > + //verify suffix first since it is the best identifier
> > + unsigned short suffix_id = ntohs(*(unsigned short*)(ptr + (cnt - 2)));
> > + if (suffix_id != ETH_P_PRP)
> > + return -1;
> > +
> > + // size should also be verified
> > + unsigned short lane_size_field = ntohs(*(unsigned short*)(ptr + (cnt -
> 4)));
> > + // size is lower 12 bits
> > + unsigned short lsdu_size = (lane_size_field & 0x0FFF);
> > + if (lsdu_size == cnt)
> > + return 0;
> > +
> > + return -1;
> > +}
> > +
> >  static int raw_open(struct transport *t, struct interface *iface,
> >      struct fdarray *fda, enum timestamp_type ts_type)
> >  {
> > @@ -287,6 +308,9 @@ static int raw_recv(struct transport *t, int fd,
> void *buf, int buflen,
> >   if (cnt < 0)
> >   return cnt;
> >
> > + if (has_prp_trailer(buf, cnt) == 0)
> > + cnt -= PRP_TRAILER_LEN;
> > +
> >   if (raw->vlan) {
> >   if (ETH_P_1588 == ntohs(hdr->type)) {
> >   pr_notice("raw: disabling VLAN mode");
> > --
> > 2.25.1
> >
>
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to