[Differential] D9270: Add support for user-supplied Host-Uniq tag and handle PADM messages in Netgraph PPPoE

2017-04-04 Thread ale (Alex Dupre)
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

2017-04-04 Thread ale (Alex Dupre)
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=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 @@
 	  _parse_uint16_type,
 	  NULL
 	},
+{
+	  NGM_PPPOE_COOKIE,
+	  NGM_PPPOE_SEND_HURL,
+	  "send_hurl",
+	  _init_data_state_type,
+	  NULL
+},
+{
+	  NGM_PPPOE_COOKIE,
+	  NGM_PPPOE_SEND_MOTM,
+	  "send_motm",
+	  _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, >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, >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);
 }
@@ -744,17 +782,29 @@
 		case 

[Differential] D9270: Add support for user-supplied Host-Uniq tag and handle PADM messages in Netgraph PPPoE

2017-04-04 Thread ale (Alex Dupre)
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

2017-04-04 Thread glebius (Gleb Smirnoff)
glebius requested changes to this revision.
glebius added a comment.
This revision now requires changes to proceed.


  I got few minor comments.

INLINE COMMENTS

> ng_pppoe.c:1135
> + /* Generate a packet of that type. */
> + MGETHDR(m, M_NOWAIT, MT_DATA);
> + if (m == NULL)

This is deprecated macro. Please use m_gethdr(M_NOWAIT, MT_DATA);

> ng_pppoe.c:1144
> +
> + m->m_pkthdr.rcvif = NULL;
> + m->m_pkthdr.len = m->m_len = sizeof(*wh);

This is already done by the allocator. Not needed.

> ng_pppoe.c:1145
> + m->m_pkthdr.rcvif = NULL;
> + m->m_pkthdr.len = m->m_len = sizeof(*wh);
> + wh = mtod(m, struct pppoe_full_hdr *);

Looks like m_pkthdr.len is never read before it is overwritten later in L1167.

> ng_pppoe.c:1180
> + /* Generate a packet of that type. */
> + MGETHDR(m, M_NOWAIT, MT_DATA);
> + if (m == NULL)

Same comments on this block as on SEND_HURL.

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"


[Bug 217637] One TCP connection accepted TWO times

2017-04-04 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217637

--- Comment #80 from Michael Tuexen  ---
I put a patch under review: https://reviews.freebsd.org/D10272

If syncookies are used in case of an overflow of the syncache, its usage is
restricted to the case where there was an overflow recently. This mitigates the
problem describe in the PR.

I'm still investing the behaviour in case of close()/shutdown(,SHUT_RD) and
received user data.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
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"