Skip to content

unspec incorrectly used #5

@rozhuk-im

Description

@rozhuk-im
+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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions