Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unspec incorrectly used #5

Open
rozhuk-im opened this issue Oct 30, 2023 · 0 comments
Open

unspec incorrectly used #5

rozhuk-im opened this issue Oct 30, 2023 · 0 comments

Comments

@rozhuk-im
Copy link

rozhuk-im commented Oct 30, 2023

+unspec:
+    header->family_transport |= NGX_PROXY_PROTOCOL_V2_FAM_UNSPEC;
+    header->len = 0;

this keep family_transport with NGX_PROXY_PROTOCOL_V2_TRANS_STREAM set.
Also NGX_PROXY_PROTOCOL_V2_FAM_UNSPEC = 0 so this code does nothing.
header->family_transport &= ~NGX_PROXY_PROTOCOL_V2_FAM_MASK; - usually this way used to unset some bits.

I do expect that family_transport = 0, to set both: family and transport to unspec at same time to not confuse parser code.

PS:

typedef struct proxy_protocol_v2_hdr_s {
	uint8_t		sig[12];/* signature hex: 0d 0a 0d 0a 00 0d 0a 51 55 49 54 0a */
	uint8_t		cmd:4;	/* Command. */
	uint8_t		ver:4;	/* Protocol version. */
	uint8_t		type:4;	/* Transport protocol type. */
	uint8_t		af:4;	/* Protocol Address family. */
	uint16_t	len;	/* Number of following bytes part of the header in network endian order. */
} __attribute__((__packed__)) pp2_hdr_t, *pp2_hdr_p;

this definition allow to work with ver/cmd/af/type without bit hacks in code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant