[Differential] D9270: Add support for user-supplied Host-Uniq tag and handle PADM messages in Netgraph PPPoE
ale added a comment. I'd like to see this in the next 11.2-RELEASE. @eugen_grosbein.net can you please commit it and MFH? REPOSITORY rS FreeBSD src repository REVISION DETAIL https://reviews.freebsd.org/D9270 EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: ale, #manpages, wblock, #network, julian, mav, adrian, glebius, franco_opnsense.org, eugen_grosbein.net Cc: garga, eugen_grosbein.net, franco_opnsense.org, mleone87_hotmail.com, glebius, wblock, mav, poolroom_gmail.com, imp, freebsd-net-list ___ freebsd-net@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"
[Differential] D9270: Add support for user-supplied Host-Uniq tag and handle PADM messages in Netgraph PPPoE
ale updated this revision to Diff 32487. ale added a comment. The updated patch fixes the reported issue on multiple PADO replies after the session has been already established. REPOSITORY rS FreeBSD src repository CHANGES SINCE LAST UPDATE https://reviews.freebsd.org/D9270?vs=27059&id=32487 REVISION DETAIL https://reviews.freebsd.org/D9270 AFFECTED FILES share/man/man4/ng_pppoe.4 sys/netgraph/ng_pppoe.c sys/netgraph/ng_pppoe.h EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: ale, #manpages, wblock, #network, julian, mav, adrian, glebius Cc: garga, eugen_grosbein.net, franco_opnsense.org, mleone87_hotmail.com, glebius, wblock, mav, poolroom_gmail.com, mandree, imp, freebsd-net-list diff --git a/sys/netgraph/ng_pppoe.h b/sys/netgraph/ng_pppoe.h --- a/sys/netgraph/ng_pppoe.h +++ b/sys/netgraph/ng_pppoe.h @@ -52,8 +52,10 @@ #define NGM_PPPOE_COOKIE 1089893072 #define NGM_PPPOE_SETMAXP_COOKIE 1441624322 +#define NGM_PPPOE_PADM_COOKIE 1488405822 #define PPPOE_SERVICE_NAME_SIZE 64 /* for now */ +#define PPPOE_PADM_VALUE_SIZE 128 /* for now */ /* Hook names */ #define NG_PPPOE_HOOK_ETHERNET "ethernet" @@ -84,7 +86,11 @@ NGM_PPPOE_SETMODE = 12, /* set to standard or compat modes */ NGM_PPPOE_GETMODE = 13, /* see current mode */ NGM_PPPOE_SETENADDR = 14, /* set Ethernet address */ - NGM_PPPOE_SETMAXP = 15 /* Set PPP-Max-Payload value */ + NGM_PPPOE_SETMAXP = 15, /* Set PPP-Max-Payload value */ + NGM_PPPOE_SEND_HURL = 16, /* Send PADM HURL message */ + NGM_PPPOE_HURL = 17, /* HURL for informational purposes */ + NGM_PPPOE_SEND_MOTM = 18, /* Send PADM MOTM message */ + NGM_PPPOE_MOTM = 19 /* MOTM for informational purposes */ }; /*** @@ -157,6 +163,13 @@ uint16_t data; }; +/* + * This structure is used to send PADM messages from server to client. + */ +struct ngpppoe_padm { + char msg[PPPOE_PADM_VALUE_SIZE]; +}; + / * Constants and definitions specific to pppoe / @@ -171,6 +184,7 @@ #define PADR_CODE 0x19 #define PADS_CODE 0x65 #define PADT_CODE 0xa7 +#define PADM_CODE 0xd3 /* Tag identifiers */ #if BYTE_ORDER == BIG_ENDIAN @@ -181,6 +195,8 @@ #define PTT_AC_COOKIE (0x0104) #define PTT_VENDOR (0x0105) #define PTT_RELAY_SID (0x0110) +#define PTT_HURL (0x0111) /* PPPoE Extensions (CARREL) */ +#define PTT_MOTM (0x0112) /* PPPoE Extensions (CARREL) */ #define PTT_MAX_PAYL (0x0120) /* PPP-Max-Payload (RFC4638) */ #define PTT_SRV_ERR (0x0201) #define PTT_SYS_ERR (0x0202) @@ -198,6 +214,8 @@ #define PTT_AC_COOKIE (0x0401) #define PTT_VENDOR (0x0501) #define PTT_RELAY_SID (0x1001) +#define PTT_HURL (0x1101) /* PPPoE Extensions (CARREL) */ +#define PTT_MOTM (0x1201) /* PPPoE Extensions (CARREL) */ #define PTT_MAX_PAYL (0x2001) /* PPP-Max-Payload (RFC4638) */ #define PTT_SRV_ERR (0x0102) #define PTT_SYS_ERR (0x0202) diff --git a/sys/netgraph/ng_pppoe.c b/sys/netgraph/ng_pppoe.c --- a/sys/netgraph/ng_pppoe.c +++ b/sys/netgraph/ng_pppoe.c @@ -175,6 +175,20 @@ &ng_parse_uint16_type, NULL }, +{ + NGM_PPPOE_COOKIE, + NGM_PPPOE_SEND_HURL, + "send_hurl", + &ngpppoe_init_data_state_type, + NULL +}, +{ + NGM_PPPOE_COOKIE, + NGM_PPPOE_SEND_MOTM, + "send_motm", + &ngpppoe_init_data_state_type, + NULL +}, { 0 } }; @@ -226,9 +240,11 @@ const struct pppoe_tag *tags[NUMTAGS]; u_int service_len; u_int ac_name_len; + u_int host_uniq_len; struct datatag service; struct datatag ac_name; + struct datatag host_uniq; }; typedef struct sess_neg *negp; @@ -589,18 +605,43 @@ pppoe_finduniq(node_p node, const struct pppoe_tag *tag) { hook_p hook = NULL; - union uniq uniq; + sessp sp; - bcopy(tag + 1, uniq.bytes, sizeof(void *)); /* Cycle through all known hooks. */ LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) { /* Skip any nonsession hook. */ if (NG_HOOK_PRIVATE(hook) == NULL) continue; - if (uniq.pointer == NG_HOOK_PRIVATE(hook)) + sp = NG_HOOK_PRIVATE(hook); + /* Skip already connected sessions. */ + if (sp->neg == NULL) + continue; + if (sp->neg->host_uniq_len == ntohs(tag->tag_len) && + bcmp(sp->neg->host_uniq.data, (const char *)(tag + 1), + sp->neg->host_uniq_len) == 0) break; } - CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, uniq.pointer); + CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, sp); + + return (hook); +} + +static hook_p +pppoe_findcookie(node_p node, const struct pppoe_tag *tag) +{ + hook_p hook = NULL; + union uniq cookie; + + bcopy(tag + 1, cookie.bytes, sizeof(void *)); + /* Cycle through all known hooks. */ + LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) { + /* Skip any nonsession hook. */ + if (NG_HOOK_PRIVATE(hook) == NULL) + continue; + if (cookie.pointer == NG_HOOK_PRIVATE
[Differential] D9270: Add support for user-supplied Host-Uniq tag and handle PADM messages in Netgraph PPPoE
ale added a comment. > How the tag should be defined in mpd.conf then? > > set auth host-uniq "string" ? No, to just set the host-uniq string you should use: set pppoe service "string|" REPOSITORY rS FreeBSD src repository REVISION DETAIL https://reviews.freebsd.org/D9270 EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: ale, #manpages, wblock, #network, julian, mav, adrian, glebius Cc: franco_opnsense.org, mleone87_hotmail.com, glebius, wblock, mav, poolroom_gmail.com, mandree, imp, freebsd-net-list ___ freebsd-net@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"
[Differential] D9270: Add support for user-supplied Host-Uniq tag and handle PADM messages in Netgraph PPPoE
ale marked 5 inline comments as done. REPOSITORY rS FreeBSD src repository REVISION DETAIL https://reviews.freebsd.org/D9270 EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: ale, #manpages, wblock, #network, julian, mav, adrian, glebius Cc: glebius, wblock, mav, poolroom_gmail.com, mandree, imp, freebsd-net-list ___ freebsd-net@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"
[Differential] D9270: Add support for user-supplied Host-Uniq tag and handle PADM messages in Netgraph PPPoE
ale updated this revision to Diff 27059. ale added a comment. Addressed latest comments, updated also the pppoe disconnect function. Please check the correctness, and commit the patch if you are satisfied. REPOSITORY rS FreeBSD src repository CHANGES SINCE LAST UPDATE https://reviews.freebsd.org/D9270?vs=25977&id=27059 REVISION DETAIL https://reviews.freebsd.org/D9270 AFFECTED FILES share/man/man4/ng_pppoe.4 sys/netgraph/ng_pppoe.c sys/netgraph/ng_pppoe.h EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: ale, #manpages, wblock, #network, julian, mav, adrian, glebius Cc: glebius, wblock, mav, poolroom_gmail.com, mandree, imp, freebsd-net-list diff --git a/sys/netgraph/ng_pppoe.h b/sys/netgraph/ng_pppoe.h --- a/sys/netgraph/ng_pppoe.h +++ b/sys/netgraph/ng_pppoe.h @@ -52,8 +52,10 @@ #define NGM_PPPOE_COOKIE 1089893072 #define NGM_PPPOE_SETMAXP_COOKIE 1441624322 +#define NGM_PPPOE_PADM_COOKIE 1488405822 #define PPPOE_SERVICE_NAME_SIZE 64 /* for now */ +#define PPPOE_PADM_VALUE_SIZE 128 /* for now */ /* Hook names */ #define NG_PPPOE_HOOK_ETHERNET "ethernet" @@ -84,7 +86,11 @@ NGM_PPPOE_SETMODE = 12, /* set to standard or compat modes */ NGM_PPPOE_GETMODE = 13, /* see current mode */ NGM_PPPOE_SETENADDR = 14, /* set Ethernet address */ - NGM_PPPOE_SETMAXP = 15 /* Set PPP-Max-Payload value */ + NGM_PPPOE_SETMAXP = 15, /* Set PPP-Max-Payload value */ + NGM_PPPOE_SEND_HURL = 16, /* Send PADM HURL message */ + NGM_PPPOE_HURL = 17, /* HURL for informational purposes */ + NGM_PPPOE_SEND_MOTM = 18, /* Send PADM MOTM message */ + NGM_PPPOE_MOTM = 19 /* MOTM for informational purposes */ }; /*** @@ -157,6 +163,13 @@ uint16_t data; }; +/* + * This structure is used to send PADM messages from server to client. + */ +struct ngpppoe_padm { + char msg[PPPOE_PADM_VALUE_SIZE]; +}; + / * Constants and definitions specific to pppoe / @@ -171,6 +184,7 @@ #define PADR_CODE 0x19 #define PADS_CODE 0x65 #define PADT_CODE 0xa7 +#define PADM_CODE 0xd3 /* Tag identifiers */ #if BYTE_ORDER == BIG_ENDIAN @@ -181,6 +195,8 @@ #define PTT_AC_COOKIE (0x0104) #define PTT_VENDOR (0x0105) #define PTT_RELAY_SID (0x0110) +#define PTT_HURL (0x0111) /* PPPoE Extensions (CARREL) */ +#define PTT_MOTM (0x0112) /* PPPoE Extensions (CARREL) */ #define PTT_MAX_PAYL (0x0120) /* PPP-Max-Payload (RFC4638) */ #define PTT_SRV_ERR (0x0201) #define PTT_SYS_ERR (0x0202) @@ -198,6 +214,8 @@ #define PTT_AC_COOKIE (0x0401) #define PTT_VENDOR (0x0501) #define PTT_RELAY_SID (0x1001) +#define PTT_HURL (0x1101) /* PPPoE Extensions (CARREL) */ +#define PTT_MOTM (0x1201) /* PPPoE Extensions (CARREL) */ #define PTT_MAX_PAYL (0x2001) /* PPP-Max-Payload (RFC4638) */ #define PTT_SRV_ERR (0x0102) #define PTT_SYS_ERR (0x0202) diff --git a/sys/netgraph/ng_pppoe.c b/sys/netgraph/ng_pppoe.c --- a/sys/netgraph/ng_pppoe.c +++ b/sys/netgraph/ng_pppoe.c @@ -175,6 +175,20 @@ &ng_parse_uint16_type, NULL }, +{ + NGM_PPPOE_COOKIE, + NGM_PPPOE_SEND_HURL, + "send_hurl", + &ngpppoe_init_data_state_type, + NULL +}, +{ + NGM_PPPOE_COOKIE, + NGM_PPPOE_SEND_MOTM, + "send_motm", + &ngpppoe_init_data_state_type, + NULL +}, { 0 } }; @@ -226,9 +240,11 @@ const struct pppoe_tag *tags[NUMTAGS]; u_int service_len; u_int ac_name_len; + u_int host_uniq_len; struct datatag service; struct datatag ac_name; + struct datatag host_uniq; }; typedef struct sess_neg *negp; @@ -589,18 +605,40 @@ pppoe_finduniq(node_p node, const struct pppoe_tag *tag) { hook_p hook = NULL; - union uniq uniq; + sessp sp; + + /* Cycle through all known hooks. */ + LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) { + /* Skip any nonsession hook. */ + if (NG_HOOK_PRIVATE(hook) == NULL) + continue; + sp = NG_HOOK_PRIVATE(hook); + if (sp->neg->host_uniq_len == ntohs(tag->tag_len) && + bcmp(sp->neg->host_uniq.data, (const char *)(tag + 1), + sp->neg->host_uniq_len) == 0) + break; + } + CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, sp); + + return (hook); +} + +static hook_p +pppoe_findcookie(node_p node, const struct pppoe_tag *tag) +{ + hook_p hook = NULL; + union uniq cookie; - bcopy(tag + 1, uniq.bytes, sizeof(void *)); + bcopy(tag + 1, cookie.bytes, sizeof(void *)); /* Cycle through all known hooks. */ LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) { /* Skip any nonsession hook. */ if (NG_HOOK_PRIVATE(hook) == NULL) continue; - if (uniq.pointer == NG_HOOK_PRIVATE(hook)) + if (cookie.pointer == NG_HOOK_PRIVATE(hook)) break; } - CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, uniq.pointer); + CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, cookie.pointer); return (hook); } @
[Differential] D9270: Add support for user-supplied Host-Uniq tag and handle PADM messages in Netgraph PPPoE
ale added a comment. The three mentioned comments apply also to the ng_pppoe_disconnect function at line 2030 from which I took inspiration, do you want me to change that function, too? REPOSITORY rS FreeBSD src repository REVISION DETAIL https://reviews.freebsd.org/D9270 EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: ale, #manpages, wblock, #network, julian, mav, adrian, glebius Cc: glebius, wblock, mav, poolroom_gmail.com, mandree, imp, freebsd-net-list ___ freebsd-net@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"
[Differential] D9270: Add support for user-supplied Host-Uniq tag and handle PADM messages in Netgraph PPPoE
ale added a comment. This revision now requires review to proceed. Who is going to commit it in the src tree and merge in 11 branch? REPOSITORY rS FreeBSD src repository REVISION DETAIL https://reviews.freebsd.org/D9270 EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: ale, #manpages, wblock, #network, julian, mav, adrian Cc: wblock, mav, poolroom_gmail.com, mandree, imp, freebsd-net-list ___ freebsd-net@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"
[Differential] D9270: Add support for user-supplied Host-Uniq tag and handle PADM messages in Netgraph PPPoE
ale marked 14 inline comments as done. REPOSITORY rS FreeBSD src repository REVISION DETAIL https://reviews.freebsd.org/D9270 EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: ale, julian, #manpages, mav, #network, adrian Cc: wblock, mav, poolroom_gmail.com, mandree, imp, freebsd-net-list ___ freebsd-net@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"
[Differential] D9270: Add support for user-supplied Host-Uniq tag and handle PADM messages in Netgraph PPPoE
ale updated this revision to Diff 25977. ale added a comment. This revision now requires review to proceed. Man page improvements REPOSITORY rS FreeBSD src repository CHANGES SINCE LAST UPDATE https://reviews.freebsd.org/D9270?vs=25849&id=25977 REVISION DETAIL https://reviews.freebsd.org/D9270 AFFECTED FILES share/man/man4/ng_pppoe.4 sys/netgraph/ng_pppoe.c sys/netgraph/ng_pppoe.h EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: ale, julian, #manpages, mav, #network, adrian Cc: wblock, mav, poolroom_gmail.com, mandree, imp, freebsd-net-list diff --git a/sys/netgraph/ng_pppoe.h b/sys/netgraph/ng_pppoe.h --- a/sys/netgraph/ng_pppoe.h +++ b/sys/netgraph/ng_pppoe.h @@ -52,8 +52,10 @@ #define NGM_PPPOE_COOKIE 1089893072 #define NGM_PPPOE_SETMAXP_COOKIE 1441624322 +#define NGM_PPPOE_PADM_COOKIE 1488405822 #define PPPOE_SERVICE_NAME_SIZE 64 /* for now */ +#define PPPOE_PADM_VALUE_SIZE 128 /* for now */ /* Hook names */ #define NG_PPPOE_HOOK_ETHERNET "ethernet" @@ -84,7 +86,11 @@ NGM_PPPOE_SETMODE = 12, /* set to standard or compat modes */ NGM_PPPOE_GETMODE = 13, /* see current mode */ NGM_PPPOE_SETENADDR = 14, /* set Ethernet address */ - NGM_PPPOE_SETMAXP = 15 /* Set PPP-Max-Payload value */ + NGM_PPPOE_SETMAXP = 15, /* Set PPP-Max-Payload value */ + NGM_PPPOE_SEND_HURL = 16, /* Send PADM HURL message */ + NGM_PPPOE_HURL = 17, /* HURL for informational purposes */ + NGM_PPPOE_SEND_MOTM = 18, /* Send PADM MOTM message */ + NGM_PPPOE_MOTM = 19 /* MOTM for informational purposes */ }; /*** @@ -157,6 +163,13 @@ uint16_t data; }; +/* + * This structure is used to send PADM messages from server to client. + */ +struct ngpppoe_padm { + char msg[PPPOE_PADM_VALUE_SIZE]; +}; + / * Constants and definitions specific to pppoe / @@ -171,6 +184,7 @@ #define PADR_CODE 0x19 #define PADS_CODE 0x65 #define PADT_CODE 0xa7 +#define PADM_CODE 0xd3 /* Tag identifiers */ #if BYTE_ORDER == BIG_ENDIAN @@ -181,6 +195,8 @@ #define PTT_AC_COOKIE (0x0104) #define PTT_VENDOR (0x0105) #define PTT_RELAY_SID (0x0110) +#define PTT_HURL (0x0111) /* PPPoE Extensions (CARREL) */ +#define PTT_MOTM (0x0112) /* PPPoE Extensions (CARREL) */ #define PTT_MAX_PAYL (0x0120) /* PPP-Max-Payload (RFC4638) */ #define PTT_SRV_ERR (0x0201) #define PTT_SYS_ERR (0x0202) @@ -198,6 +214,8 @@ #define PTT_AC_COOKIE (0x0401) #define PTT_VENDOR (0x0501) #define PTT_RELAY_SID (0x1001) +#define PTT_HURL (0x1101) /* PPPoE Extensions (CARREL) */ +#define PTT_MOTM (0x1201) /* PPPoE Extensions (CARREL) */ #define PTT_MAX_PAYL (0x2001) /* PPP-Max-Payload (RFC4638) */ #define PTT_SRV_ERR (0x0102) #define PTT_SYS_ERR (0x0202) diff --git a/sys/netgraph/ng_pppoe.c b/sys/netgraph/ng_pppoe.c --- a/sys/netgraph/ng_pppoe.c +++ b/sys/netgraph/ng_pppoe.c @@ -175,6 +175,20 @@ &ng_parse_uint16_type, NULL }, +{ + NGM_PPPOE_COOKIE, + NGM_PPPOE_SEND_HURL, + "send_hurl", + &ngpppoe_init_data_state_type, + NULL +}, +{ + NGM_PPPOE_COOKIE, + NGM_PPPOE_SEND_MOTM, + "send_motm", + &ngpppoe_init_data_state_type, + NULL +}, { 0 } }; @@ -226,9 +240,11 @@ const struct pppoe_tag *tags[NUMTAGS]; u_int service_len; u_int ac_name_len; + u_int host_uniq_len; struct datatag service; struct datatag ac_name; + struct datatag host_uniq; }; typedef struct sess_neg *negp; @@ -589,18 +605,40 @@ pppoe_finduniq(node_p node, const struct pppoe_tag *tag) { hook_p hook = NULL; - union uniq uniq; + sessp sp; - bcopy(tag + 1, uniq.bytes, sizeof(void *)); /* Cycle through all known hooks. */ LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) { /* Skip any nonsession hook. */ if (NG_HOOK_PRIVATE(hook) == NULL) continue; - if (uniq.pointer == NG_HOOK_PRIVATE(hook)) + sp = NG_HOOK_PRIVATE(hook); + if (sp->neg->host_uniq_len == ntohs(tag->tag_len) && + bcmp(sp->neg->host_uniq.data, (const char *)(tag + 1), + sp->neg->host_uniq_len) == 0) break; } - CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, uniq.pointer); + CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, sp); + + return (hook); +} + +static hook_p +pppoe_findcookie(node_p node, const struct pppoe_tag *tag) +{ + hook_p hook = NULL; + union uniq cookie; + + bcopy(tag + 1, cookie.bytes, sizeof(void *)); + /* Cycle through all known hooks. */ + LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) { + /* Skip any nonsession hook. */ + if (NG_HOOK_PRIVATE(hook) == NULL) + continue; + if (cookie.pointer == NG_HOOK_PRIVATE(hook)) + break; + } + CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, cookie.pointer); return (hook); } @@ -744,17 +782,29 @@ case NGM_PPPOE_LISTEN: case NGM_PPPOE_OFFER: case NGM_PPPOE_SERVICE: + ca
[Differential] D9270: Add support for user-supplied Host-Uniq tag and handle PADM messages in Netgraph PPPoE
ale added a comment. Thanks for your comment, I'll improve the man page. INLINE COMMENTS > wblock wrote in ng_pppoe.4:108 > "host uniq" should be capitalized or otherwise identified with markup. Since > it's used below, just be consistent and say `Host-Uniq`. Are you fine with lower case "access concentrator"? > wblock wrote in ng_pppoe.4:109 > The formatting looks odd, but is apparently meant to show that there is an > optional AC-Name followed by double backslashes if present, followed by an > optional Host-Uniq with a vertical bar if present. Does this render > correctly? The double backslash is just for man page escaping, it's actually a single backslash. Both AC-Name and Host-Uniq are optional, that's the reason for different separators. > wblock wrote in ng_pppoe.4:118 > Markup could show these with out-of-band highlighting rather than quotes. > But I'm not sure which markup to use. I'll make a few tries, .Sq might be a good choice > wblock wrote in ng_pppoe.4:292 > "may" usually implies "you have permission", while "can" means "it is > possible". So: > > message with a HURL tag is received, and contains a URL which the Host can > > Should Host be capitalized? It's MAY in RFC 2119 meaning, but I'll change it to "can". I capitalized the Host to make it clearer what's the meaning of the H in HURL, but probably is not needed. REPOSITORY rS FreeBSD src repository REVISION DETAIL https://reviews.freebsd.org/D9270 EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: ale, #manpages, adrian, #network, julian, mav Cc: wblock, mav, poolroom_gmail.com, mandree, imp, freebsd-net-list ___ freebsd-net@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"
[Differential] D9270: Add support for user-supplied Host-Uniq tag and handle PADM messages in Netgraph PPPoE
ale retitled this revision from "Add support for user-supplied Host-Uniq tag in Netgraph PPPoE" to "Add support for user-supplied Host-Uniq tag and handle PADM messages in Netgraph PPPoE". ale updated the summary for this revision. ale updated the test plan for this revision. ale added a subscriber: mav. ale updated this revision to Diff 25849. ale added a comment. This revision now requires review to proceed. - add client and server support for PADM messages, HURL and MOTM - Fix a regression in PPPoE server introduced by previous patch version - handle missing service name tag in PADI requests to cope with non fully compliant client implementations, treat it as empty service name REPOSITORY rS FreeBSD src repository CHANGES SINCE LAST UPDATE https://reviews.freebsd.org/D9270?vs=24314&id=25849 REVISION DETAIL https://reviews.freebsd.org/D9270 AFFECTED FILES share/man/man4/ng_pppoe.4 sys/netgraph/ng_pppoe.c sys/netgraph/ng_pppoe.h EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: ale, #manpages, adrian, #network, julian Cc: mav, poolroom_gmail.com, mandree, imp, freebsd-net-list diff --git a/sys/netgraph/ng_pppoe.h b/sys/netgraph/ng_pppoe.h --- a/sys/netgraph/ng_pppoe.h +++ b/sys/netgraph/ng_pppoe.h @@ -52,8 +52,10 @@ #define NGM_PPPOE_COOKIE 1089893072 #define NGM_PPPOE_SETMAXP_COOKIE 1441624322 +#define NGM_PPPOE_PADM_COOKIE 1488405822 #define PPPOE_SERVICE_NAME_SIZE 64 /* for now */ +#define PPPOE_PADM_VALUE_SIZE 128 /* for now */ /* Hook names */ #define NG_PPPOE_HOOK_ETHERNET "ethernet" @@ -84,7 +86,11 @@ NGM_PPPOE_SETMODE = 12, /* set to standard or compat modes */ NGM_PPPOE_GETMODE = 13, /* see current mode */ NGM_PPPOE_SETENADDR = 14, /* set Ethernet address */ - NGM_PPPOE_SETMAXP = 15 /* Set PPP-Max-Payload value */ + NGM_PPPOE_SETMAXP = 15, /* Set PPP-Max-Payload value */ + NGM_PPPOE_SEND_HURL = 16, /* Send PADM HURL message */ + NGM_PPPOE_HURL = 17, /* HURL for informational purposes */ + NGM_PPPOE_SEND_MOTM = 18, /* Send PADM MOTM message */ + NGM_PPPOE_MOTM = 19 /* MOTM for informational purposes */ }; /*** @@ -157,6 +163,13 @@ uint16_t data; }; +/* + * This structure is used to send PADM messages from server to client. + */ +struct ngpppoe_padm { + char msg[PPPOE_PADM_VALUE_SIZE]; +}; + / * Constants and definitions specific to pppoe / @@ -171,6 +184,7 @@ #define PADR_CODE 0x19 #define PADS_CODE 0x65 #define PADT_CODE 0xa7 +#define PADM_CODE 0xd3 /* Tag identifiers */ #if BYTE_ORDER == BIG_ENDIAN @@ -181,6 +195,8 @@ #define PTT_AC_COOKIE (0x0104) #define PTT_VENDOR (0x0105) #define PTT_RELAY_SID (0x0110) +#define PTT_HURL (0x0111) /* PPPoE Extensions (CARREL) */ +#define PTT_MOTM (0x0112) /* PPPoE Extensions (CARREL) */ #define PTT_MAX_PAYL (0x0120) /* PPP-Max-Payload (RFC4638) */ #define PTT_SRV_ERR (0x0201) #define PTT_SYS_ERR (0x0202) @@ -198,6 +214,8 @@ #define PTT_AC_COOKIE (0x0401) #define PTT_VENDOR (0x0501) #define PTT_RELAY_SID (0x1001) +#define PTT_HURL (0x1101) /* PPPoE Extensions (CARREL) */ +#define PTT_MOTM (0x1201) /* PPPoE Extensions (CARREL) */ #define PTT_MAX_PAYL (0x2001) /* PPP-Max-Payload (RFC4638) */ #define PTT_SRV_ERR (0x0102) #define PTT_SYS_ERR (0x0202) diff --git a/sys/netgraph/ng_pppoe.c b/sys/netgraph/ng_pppoe.c --- a/sys/netgraph/ng_pppoe.c +++ b/sys/netgraph/ng_pppoe.c @@ -175,6 +175,20 @@ &ng_parse_uint16_type, NULL }, +{ + NGM_PPPOE_COOKIE, + NGM_PPPOE_SEND_HURL, + "send_hurl", + &ngpppoe_init_data_state_type, + NULL +}, +{ + NGM_PPPOE_COOKIE, + NGM_PPPOE_SEND_MOTM, + "send_motm", + &ngpppoe_init_data_state_type, + NULL +}, { 0 } }; @@ -226,9 +240,11 @@ const struct pppoe_tag *tags[NUMTAGS]; u_int service_len; u_int ac_name_len; + u_int host_uniq_len; struct datatag service; struct datatag ac_name; + struct datatag host_uniq; }; typedef struct sess_neg *negp; @@ -589,18 +605,40 @@ pppoe_finduniq(node_p node, const struct pppoe_tag *tag) { hook_p hook = NULL; - union uniq uniq; + sessp sp; - bcopy(tag + 1, uniq.bytes, sizeof(void *)); /* Cycle through all known hooks. */ LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) { /* Skip any nonsession hook. */ if (NG_HOOK_PRIVATE(hook) == NULL) continue; - if (uniq.pointer == NG_HOOK_PRIVATE(hook)) + sp = NG_HOOK_PRIVATE(hook); + if (sp->neg->host_uniq_len == ntohs(tag->tag_len) && + bcmp(sp->neg->host_uniq.data, (const char *)(tag + 1), + sp->neg->host_uniq_len) == 0) break; } - CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, uniq.pointer); + CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, sp); + + return (hook); +} + +static hook_p +pppoe_findcookie(node_p node, const struct
[Differential] D9270: Add support for user-supplied Host-Uniq tag in Netgraph PPPoE
ale marked 2 inline comments as done. REPOSITORY rS FreeBSD src repository REVISION DETAIL https://reviews.freebsd.org/D9270 EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: ale, #network, #manpages, julian Cc: mandree, imp, freebsd-net-list ___ freebsd-net@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"
[Differential] D9270: Add support for user-supplied Host-Uniq tag in Netgraph PPPoE
ale updated this revision to Diff 24314. ale added a comment. This revision now requires review to proceed. Fixed typos and improved man page. REPOSITORY rS FreeBSD src repository CHANGES SINCE LAST UPDATE https://reviews.freebsd.org/D9270?vs=24264&id=24314 REVISION DETAIL https://reviews.freebsd.org/D9270 AFFECTED FILES share/man/man4/ng_pppoe.4 sys/netgraph/ng_pppoe.c EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: ale, #network, #manpages, julian Cc: mandree, imp, freebsd-net-list diff --git a/sys/netgraph/ng_pppoe.c b/sys/netgraph/ng_pppoe.c --- a/sys/netgraph/ng_pppoe.c +++ b/sys/netgraph/ng_pppoe.c @@ -226,9 +226,11 @@ const struct pppoe_tag *tags[NUMTAGS]; u_int service_len; u_int ac_name_len; + u_int host_uniq_len; struct datatag service; struct datatag ac_name; + struct datatag host_uniq; }; typedef struct sess_neg *negp; @@ -589,18 +591,20 @@ pppoe_finduniq(node_p node, const struct pppoe_tag *tag) { hook_p hook = NULL; - union uniq uniq; + sessp sp; - bcopy(tag + 1, uniq.bytes, sizeof(void *)); /* Cycle through all known hooks. */ LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) { /* Skip any nonsession hook. */ if (NG_HOOK_PRIVATE(hook) == NULL) continue; - if (uniq.pointer == NG_HOOK_PRIVATE(hook)) + sp = NG_HOOK_PRIVATE(hook); + if (sp->neg->host_uniq_len == ntohs(tag->tag_len) && + bcmp(sp->neg->host_uniq.data, (const char *)(tag + 1), + sp->neg->host_uniq_len) == 0) break; } - CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, uniq.pointer); + CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, sp); return (hook); } @@ -848,28 +852,72 @@ * Check the hook exists and is Uninitialised. * Send a PADI request, and start the timeout logic. * Store the originator of this message so we can send - * a success of fail message to them later. + * a success or fail message to them later. * Move the session to SINIT. * Set up the session to the correct state and * start it. */ - int i, acnlen = 0, acnsep = 0, srvlen; + int acnpos, acnlen = 0, acnsep = 0; + int hupos, hulen = 0, husep = 0; + int i, srvpos, srvlen; + acnpos = 0; for (i = 0; i < ourmsg->data_len; i++) { if (ourmsg->data[i] == '\\') { acnlen = i; acnsep = 1; break; } } - srvlen = ourmsg->data_len - acnlen - acnsep; + hupos = acnlen + acnsep; + for (i = hupos; i < ourmsg->data_len; i++) { +if (ourmsg->data[i] == '|') { + hulen = i - hupos; + husep = 1; + break; +} + } + srvpos = hupos + hulen + husep; + srvlen = ourmsg->data_len - srvpos; - bcopy(ourmsg->data, neg->ac_name.data, acnlen); + bcopy(ourmsg->data + acnpos, neg->ac_name.data, acnlen); neg->ac_name_len = acnlen; + neg->host_uniq.hdr.tag_type = PTT_HOST_UNIQ; + if (hulen == 0) { +/* Not provided, generate one */ +neg->host_uniq.hdr.tag_len = htons(sizeof(sp)); +bcopy(&sp, neg->host_uniq.data, sizeof(sp)); +neg->host_uniq_len = sizeof(sp); + } else if (hulen > 2 && ourmsg->data[hupos] == '0' && + ourmsg->data[hupos + 1] == 'x' && hulen % 2 == 0) { +/* Hex encoded */ +static const char hexdig[16] = "0123456789abcdef"; +int j; + +neg->host_uniq.hdr.tag_len = htons((uint16_t)(hulen / 2 - 1)); +for (i = 0; i < hulen - 2; i++) { + for (j = 0; + j < 16 && + ourmsg->data[hupos + 2 + i] != hexdig[j]; + j++); + if (j == 16) + LEAVE(EINVAL); + if (i % 2 == 0) + neg->host_uniq.data[i / 2] = j << 4; + else + neg->host_uniq.data[i / 2] |= j; +} +neg->host_uniq_len = hulen / 2 - 1; + } else { +/* Plain string */ +neg->host_uniq.hdr.tag_len = htons((uint16_t)hulen); +bcopy(ourmsg->data + hupos, neg->host_uniq.data, hulen); +neg->host_uniq_len = hulen; + } + neg->service.hdr.tag_type = PTT_SRV_NAME; neg->service.hdr.tag_len = htons((uint16_t)srvlen); - bcopy(ourmsg->data + acnlen + acnsep, - neg->service.data, srvlen); + bcopy(ourmsg->data + srvpos, neg->service.data, srvlen); neg->service_len = srvlen; pppoe_start(sp); break; @@ -879,7 +927,7 @@ * Check the hook exists and is Uninitialised. * Install the service matching string. * Store the originator of this message so we can send - * a success of fail message to them later. + * a success or fail message to them later. * Move the hook to 'LISTENING' */ neg->service.hdr.tag_type = PTT_SRV_NAME; @@ -1061,10 +1109,6 @@ node_p node = NG_HOOK_NODE(hook); priv_p privp = NG_NODE_PRIVATE(node); negp neg = sp->neg; - struct { - struct pppoe_tag hdr; - union uniq data; - } __packed uniqtag; struct mbuf *m0; int error; @@ -1080,11 +1124,8 @@ memcpy((void *)&neg->pkt->pkt_header.eh, &privp->eh, sizeof(struct ether_header)); neg->pkt->pkt_header.ph.code = PADI_CODE; - uniqtag.hdr.ta
[Differential] D9270: Add support for user-supplied Host-Uniq tag in Netgraph PPPoE
ale created this revision. ale added reviewers: network, julian. ale added subscribers: freebsd-net-list, mandree. ale set the repository for this revision to rS FreeBSD src repository. Herald added a subscriber: imp. Herald added a reviewer: manpages. REVISION SUMMARY Add support for user-supplied Host-Uniq tag in Netgraph PPPoE. A few ISP filter PADI requests based on such tag, to force the use of their own routers. The custom Host-Uniq tag is passed in the NGM_PPPOE_CONNECT control message, so it can be used with FreeBSD ppp(8) without any other change. TEST PLAN I've tested the three possible Host-Uniq tags (auto-generated as before, long plain string and long binary string) with my own ISP connection. REPOSITORY rS FreeBSD src repository REVISION DETAIL https://reviews.freebsd.org/D9270 AFFECTED FILES share/man/man4/ng_pppoe.4 sys/netgraph/ng_pppoe.c EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: ale, #network, #manpages, julian Cc: mandree, imp, freebsd-net-list diff --git a/sys/netgraph/ng_pppoe.c b/sys/netgraph/ng_pppoe.c --- a/sys/netgraph/ng_pppoe.c +++ b/sys/netgraph/ng_pppoe.c @@ -226,9 +226,11 @@ const struct pppoe_tag *tags[NUMTAGS]; u_int service_len; u_int ac_name_len; + u_int host_uniq_len; struct datatag service; struct datatag ac_name; + struct datatag host_uniq; }; typedef struct sess_neg *negp; @@ -589,18 +591,20 @@ pppoe_finduniq(node_p node, const struct pppoe_tag *tag) { hook_p hook = NULL; - union uniq uniq; + sessp sp; - bcopy(tag + 1, uniq.bytes, sizeof(void *)); /* Cycle through all known hooks. */ LIST_FOREACH(hook, &node->nd_hooks, hk_hooks) { /* Skip any nonsession hook. */ if (NG_HOOK_PRIVATE(hook) == NULL) continue; - if (uniq.pointer == NG_HOOK_PRIVATE(hook)) + sp = NG_HOOK_PRIVATE(hook); + if (sp->neg->host_uniq_len == ntohs(tag->tag_len) && + bcmp(sp->neg->host_uniq.data, (const char *)(tag + 1), + sp->neg->host_uniq_len) == 0) break; } - CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, uniq.pointer); + CTR3(KTR_NET, "%20s: matched %p for %p", __func__, hook, sp); return (hook); } @@ -853,23 +857,67 @@ * Set up the session to the correct state and * start it. */ - int i, acnlen = 0, acnsep = 0, srvlen; + int acnpos, acnlen = 0, acnsep = 0; + int hupos, hulen = 0, husep = 0; + int i, srvpos, srvlen; + acnpos = 0; for (i = 0; i < ourmsg->data_len; i++) { if (ourmsg->data[i] == '\\') { acnlen = i; acnsep = 1; break; } } - srvlen = ourmsg->data_len - acnlen - acnsep; + hupos = acnlen + acnsep; + for (i = hupos; i < ourmsg->data_len; i++) { +if (ourmsg->data[i] == '|') { + hulen = i - hupos; + husep = 1; + break; +} + } + srvpos = hupos + hulen + husep; + srvlen = ourmsg->data_len - srvpos; - bcopy(ourmsg->data, neg->ac_name.data, acnlen); + bcopy(ourmsg->data + acnpos, neg->ac_name.data, acnlen); neg->ac_name_len = acnlen; + neg->host_uniq.hdr.tag_type = PTT_HOST_UNIQ; + if (hulen == 0) { +/* Not provided, generate one */ +neg->host_uniq.hdr.tag_len = htons(sizeof(sp)); +bcopy(&sp, neg->host_uniq.data, sizeof(sp)); +neg->host_uniq_len = sizeof(sp); + } else if (hulen > 2 && ourmsg->data[hupos] == '0' && + ourmsg->data[hupos + 1] == 'x' && hulen % 2 == 0) { +/* Hex encoded */ +static const char hexdig[16] = "0123456789abcdef"; +int j; + +neg->host_uniq.hdr.tag_len = htons((uint16_t)(hulen / 2 - 1)); +for (i = 0; i < hulen - 2; i++) { + for (j = 0; + j < 16 && + ourmsg->data[hupos + 2 + i] != hexdig[j]; + j++); + if (j == 16) + LEAVE(EINVAL); + if (i % 2 == 0) + neg->host_uniq.data[i / 2] = j << 4; + else + neg->host_uniq.data[i / 2] |= j; +} +neg->host_uniq_len = hulen / 2 - 1; + } else { +/* Plain string */ +neg->host_uniq.hdr.tag_len = htons((uint16_t)hulen); +bcopy(ourmsg->data + hupos, neg->host_uniq.data, hulen); +neg->host_uniq_len = hulen; + } + neg->service.hdr.tag_type = PTT_SRV_NAME; neg->service.hdr.tag_len = htons((uint16_t)srvlen); - bcopy(ourmsg->data + acnlen + acnsep, - neg->service.data, srvlen); + bcopy(ourmsg->data + srvpos, neg->service.data, srvlen); neg->service_len = srvlen; pppoe_start(sp); break; @@ -1061,10 +1109,6 @@ node_p node = NG_HOOK_NODE(hook); priv_p privp = NG_NODE_PRIVATE(node); negp neg = sp->neg; - struct { - struct pppoe_tag hdr; - union uniq data; - } __packed uniqtag; struct mbuf *m0; int error; @@ -1080,11 +1124,8 @@ memcpy((void *)&neg->pkt->pkt_header.eh, &privp->eh, sizeof(struct ether_header)); neg->pkt->pkt_header.ph.code = PADI_CODE; - uniqtag.hdr.tag_type = PTT_HOST_UNIQ; - uniqtag.hdr.tag_len = htons((u_int16_t)sizeof(uniqtag.data)); - uniqtag.data.pointer = sp; init_tags(sp); - insert_tag(sp, &uniq