From: Willy Tarreau Date: Mon, 28 Jun 2021 05:12:22 +0000 (+0200) Subject: BUILD: tcp-act: avoid warning when set-mark / set-tos are not supported X-Git-Tag: v2.5-dev1~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5bbfff107bb8b5bcb2d7985f0ec0769139c89235;p=thirdparty%2Fhaproxy.git BUILD: tcp-act: avoid warning when set-mark / set-tos are not supported Since recent commit 469c06c30 ("MINOR: http-act/tcp-act: Add "set-mark" and "set-tos" for tcp content rules") there's a build warning (or error) on Windows due to static function tcp_action_set_mark() not being used because the set-mark functionality is not supported there. It's caused by the fact that only the parsing function uses it so if the code is ifdefed out the function remains unused. Let's surround it with ifdefs as well, and do the same for tcp_action_set_tos() which could suffer the same fate on operating systems not defining IP_TOS. This may need to be backported if the patch above is backported. Also be careful, the condition was adjusted to cover FreeBSD after commit f7f53afcf ("BUILD/MEDIUM: tcp: set-mark setting support for FreeBSD."). --- diff --git a/src/tcp_act.c b/src/tcp_act.c index a6c58fb887..b684bff430 100644 --- a/src/tcp_act.c +++ b/src/tcp_act.c @@ -237,20 +237,23 @@ static enum act_return tcp_exec_action_silent_drop(struct act_rule *rule, struct } +#if defined(SO_MARK) || defined(SO_USER_COOKIE) static enum act_return tcp_action_set_mark(struct act_rule *rule, struct proxy *px, struct session *sess, struct stream *s, int flags) { conn_set_mark(objt_conn(sess->origin), (uintptr_t)rule->arg.act.p[0]); return ACT_RET_CONT; } +#endif +#ifdef IP_TOS static enum act_return tcp_action_set_tos(struct act_rule *rule, struct proxy *px, struct session *sess, struct stream *s, int flags) { conn_set_tos(objt_conn(sess->origin), (uintptr_t)rule->arg.act.p[0]); return ACT_RET_CONT; } - +#endif /* parse "set-{src,dst}[-port]" action */ static enum act_parse_ret tcp_parse_set_src_dst(const char **args, int *orig_arg, struct proxy *px,