Hi!

  The change definitely lacks the documentation change :)

On Fri, Sep 11, 2015 at 09:15:28AM +0000, Alexander Motin wrote:
A> Author: mav
A> Date: Fri Sep 11 09:15:27 2015
A> New Revision: 287654
A> URL: https://svnweb.freebsd.org/changeset/base/287654
A> 
A> Log:
A>   Add support for PPP-Max-Payload PPPoE tag (RFC4638).
A>   
A>   Submitted by:      Dmitry Luhtionov <dmitryluhtio...@gmail.com>
A>   MFC after: 2 weeks
A> 
A> Modified:
A>   head/sys/netgraph/ng_pppoe.c
A>   head/sys/netgraph/ng_pppoe.h
A> 
A> Modified: head/sys/netgraph/ng_pppoe.c
A> 
==============================================================================
A> --- head/sys/netgraph/ng_pppoe.c     Fri Sep 11 08:48:16 2015        
(r287653)
A> +++ head/sys/netgraph/ng_pppoe.c     Fri Sep 11 09:15:27 2015        
(r287654)
A> @@ -168,6 +168,13 @@ static const struct ng_cmdlist ng_pppoe_
A>        &ng_parse_enaddr_type,
A>        NULL
A>      },
A> +    {
A> +      NGM_PPPOE_COOKIE,
A> +      NGM_PPPOE_SETMAXP,
A> +      "setmaxp",
A> +      &ng_parse_uint16_type,
A> +      NULL
A> +    },
A>      { 0 }
A>  };
A>  
A> @@ -262,6 +269,7 @@ struct PPPoE {
A>      struct ether_header     eh;
A>      LIST_HEAD(, sess_con) listeners;
A>      struct sess_hash_entry  sesshash[SESSHASHSIZE];
A> +    struct maxptag  max_payload;    /* PPP-Max-Payload (RFC4638) */
A>  };
A>  typedef struct PPPoE *priv_p;
A>  
A> @@ -1004,6 +1012,13 @@ ng_pppoe_rcvmsg(node_p node, item_p item
A>                      bcopy(msg->data, &privp->eh.ether_shost,
A>                          ETHER_ADDR_LEN);
A>                      break;
A> +            case NGM_PPPOE_SETMAXP:
A> +                    if (msg->header.arglen != sizeof(uint16_t))
A> +                            LEAVE(EINVAL);
A> +                    privp->max_payload.hdr.tag_type = PTT_MAX_PAYL;
A> +                    privp->max_payload.hdr.tag_len = 
htons(sizeof(uint16_t));
A> +                    privp->max_payload.data = htons(*((uint16_t 
*)msg->data));
A> +                    break;
A>              default:
A>                      LEAVE(EINVAL);
A>              }
A> @@ -1071,6 +1086,8 @@ pppoe_start(sessp sp)
A>      init_tags(sp);
A>      insert_tag(sp, &uniqtag.hdr);
A>      insert_tag(sp, &neg->service.hdr);
A> +    if (privp->max_payload.data != 0)
A> +            insert_tag(sp, &privp->max_payload.hdr);
A>      make_packet(sp);
A>      /*
A>       * Send packet and prepare to retransmit it after timeout.
A> @@ -1124,6 +1141,28 @@ send_sessionid(sessp sp)
A>      return (error);
A>  }
A>  
A> +static int
A> +send_maxp(sessp sp, const struct pppoe_tag *tag)
A> +{
A> +    int error;
A> +    struct ng_mesg *msg;
A> +    struct ngpppoe_maxp *maxp;
A> +
A> +    CTR2(KTR_NET, "%20s: called %d", __func__, sp->Session_ID);
A> +
A> +    NG_MKMESSAGE(msg, NGM_PPPOE_COOKIE, NGM_PPPOE_SETMAXP,
A> +        sizeof(struct ngpppoe_maxp), M_NOWAIT);
A> +    if (msg == NULL)
A> +            return (ENOMEM);
A> +
A> +    maxp = (struct ngpppoe_maxp *)msg->data;
A> +    strncpy(maxp->hook, NG_HOOK_NAME(sp->hook), NG_HOOKSIZ);
A> +    maxp->data = ntohs(((const struct maxptag *)tag)->data);
A> +    NG_SEND_MSG_ID(error, NG_HOOK_NODE(sp->hook), msg, sp->creator, 0);
A> +
A> +    return (error);
A> +}
A> +
A>  /*
A>   * Receive data from session hook and do something with it.
A>   */
A> @@ -1464,6 +1503,9 @@ ng_pppoe_rcvdata_ether(hook_p hook, item
A>                              insert_tag(sp, tag);    /* return it */
A>                              send_acname(sp, tag);
A>                      }
A> +                    if ((tag = get_tag(ph, PTT_MAX_PAYL)) &&
A> +                        (privp->max_payload.data != 0))
A> +                            insert_tag(sp, tag);    /* return it */
A>                      insert_tag(sp, &neg->service.hdr); /* Service */
A>                      scan_tags(sp, ph);
A>                      make_packet(sp);
A> @@ -1602,6 +1644,9 @@ ng_pppoe_rcvdata_ether(hook_p hook, item
A>                      m_freem(neg->m);
A>                      free(sp->neg, M_NETGRAPH_PPPOE);
A>                      sp->neg = NULL;
A> +                    if ((tag = get_tag(ph, PTT_MAX_PAYL)) &&
A> +                        (privp->max_payload.data != 0))
A> +                            send_maxp(sp, tag);
A>                      pppoe_send_event(sp, NGM_PPPOE_SUCCESS);
A>                      break;
A>              case    PADT_CODE:
A> 
A> Modified: head/sys/netgraph/ng_pppoe.h
A> 
==============================================================================
A> --- head/sys/netgraph/ng_pppoe.h     Fri Sep 11 08:48:16 2015        
(r287653)
A> +++ head/sys/netgraph/ng_pppoe.h     Fri Sep 11 09:15:27 2015        
(r287654)
A> @@ -51,6 +51,7 @@
A>  #define NG_PPPOE_NODE_TYPE  "pppoe"
A>  
A>  #define NGM_PPPOE_COOKIE            1089893072
A> +#define NGM_PPPOE_SETMAXP_COOKIE    1441624322
A>  
A>  #define     PPPOE_SERVICE_NAME_SIZE         64 /* for now */
A>  
A> @@ -83,6 +84,7 @@ enum cmd {
A>      NGM_PPPOE_SETMODE  = 12, /* set to standard or compat modes */
A>      NGM_PPPOE_GETMODE  = 13, /* see current mode */
A>      NGM_PPPOE_SETENADDR = 14, /* set Ethernet address */
A> +    NGM_PPPOE_SETMAXP  = 15 /* Set PPP-Max-Payload value */
A>  };
A>  
A>  /***********************
A> @@ -147,6 +149,13 @@ struct ngpppoe_sts {
A>        { NULL }                                      \
A>  }
A>  
A> +/*
A> + * This structure is used to send PPP-Max-Payload value from server to 
client.
A> + */
A> +struct ngpppoe_maxp {
A> +    char    hook[NG_HOOKSIZ];       /* hook associated with event session */
A> +    uint16_t        data;
A> +};
A>  
A>  /********************************************************************
A>   * Constants and definitions specific to pppoe
A> @@ -229,6 +238,10 @@ struct datatag {
A>      u_int8_t        data[PPPOE_SERVICE_NAME_SIZE];
A>  };     
A>  
A> +struct maxptag {
A> +    struct pppoe_tag hdr;
A> +    uint16_t        data;
A> +};
A>  
A>  /*
A>   * Define the order in which we will place tags in packets
A> _______________________________________________
A> svn-src-all@freebsd.org mailing list
A> https://lists.freebsd.org/mailman/listinfo/svn-src-all
A> To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

-- 
Totus tuus, Glebius.
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to