From: Harlan Stenn Date: Wed, 3 Jun 2015 09:30:35 +0000 (+0000) Subject: [Bug 2837] Allow a configurable DSCP value X-Git-Tag: NTP_4_3_34~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9eea5ab474513da9ab9b5a5ac0fcdeabc04cf583;p=thirdparty%2Fntp.git [Bug 2837] Allow a configurable DSCP value bk: 556ec93b3y0FfQcVjiwv-X003v8hAA --- diff --git a/ChangeLog b/ChangeLog index b880aaca2..60c1fe6ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ --- * [Bug 2824] Convert update-leap to perl. (also see 2769) -* [Bug 2832] refclock_jjy.c supports the TDC-300 +* [Bug 2832] refclock_jjy.c supports the TDC-300. * [Bug 2834] Correct a broken html tag in html/refclock.html +* [Bug 2837] Allow a configurable DSCP value. --- (4.2.8p3-RC1) 2015/05/12 Released by Harlan Stenn diff --git a/html/miscopt.html b/html/miscopt.html index 5750d1799..14ab27599 100644 --- a/html/miscopt.html +++ b/html/miscopt.html @@ -170,6 +170,8 @@
The trap receiver will generally log event messages and other information from the server in a log file. While such monitor programs may also request their own trap dynamically, configuring a trap receiver will ensure that no messages are lost when the server is started.
ttl hop ...
This command specifies a list of TTL values in increasing order. up to 8 values can be specified. In manycast mode these values are used in turn in an expanding-ring search. The default is eight multiples of 32 starting at 31.
+
dscp dscp
+
This command specifies the Differentiated Services Code Point (DSCP) value that is used in sent NTP packets. The default value is 46 for Expedited Forwarding (EF).

diff --git a/include/ntp_io.h b/include/ntp_io.h index 2cdca7108..5950f0035 100644 --- a/include/ntp_io.h +++ b/include/ntp_io.h @@ -80,6 +80,7 @@ typedef enum { } nic_rule_action; +extern int qos; SOCKET move_fd(SOCKET fd); isc_boolean_t get_broadcastclient_flag(void); extern int is_ip_address(const char *, u_short, sockaddr_u *); diff --git a/ntpd/keyword-gen.c b/ntpd/keyword-gen.c index 9ca7415f1..357623038 100644 --- a/ntpd/keyword-gen.c +++ b/ntpd/keyword-gen.c @@ -46,6 +46,7 @@ struct key_tok ntp_keywords[] = { { "ctl", T_Ctl, FOLLBY_TOKEN }, { "disable", T_Disable, FOLLBY_TOKEN }, { "driftfile", T_Driftfile, FOLLBY_STRING }, +{ "dscp", T_Dscp, FOLLBY_TOKEN }, { "enable", T_Enable, FOLLBY_TOKEN }, { "end", T_End, FOLLBY_TOKEN }, { "filegen", T_Filegen, FOLLBY_TOKEN }, diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index cd734c326..bff84066f 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -3493,6 +3493,11 @@ config_vars( stats_config(STATS_FREQ_FILE, curr_var->value.s); break; + case T_Dscp: + /* DSCP is in the upper 6 bits of the IP TOS/DS field */ + qos = curr_var->value.i << 2; + break; + case T_Ident: sys_ident = curr_var->value.s; break; @@ -4291,7 +4296,6 @@ config_ntpd( ) { config_nic_rules(ptree, input_from_files); - io_open_sockets(); config_monitor(ptree); config_auth(ptree); config_tos(ptree); @@ -4306,6 +4310,9 @@ config_ntpd( config_ttl(ptree); config_trap(ptree); config_vars(ptree); + + io_open_sockets(); + config_other_modes(ptree); config_peers(ptree); config_unpeers(ptree); diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 1ee7098ae..ad1b41e42 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -73,6 +73,11 @@ extern int listen_to_virtual_ips; +#ifndef IPTOS_DSCP_EF +#define IPTOS_DSCP_EF 0xb8 +#endif +int qos = IPTOS_DSCP_EF; /* QoS RFC3246 */ + /* * NIC rule entry */ @@ -2842,11 +2847,6 @@ open_socket( int on = 1; int off = 0; -#ifndef IPTOS_DSCP_EF -#define IPTOS_DSCP_EF 0xb8 -#endif - int qos = IPTOS_DSCP_EF; /* QoS RFC3246 */ - if (IS_IPV6(addr) && !ipv6_works) return INVALID_SOCKET; diff --git a/ntpd/ntp_parser.y b/ntpd/ntp_parser.y index 0a469adcc..c64594c1c 100644 --- a/ntpd/ntp_parser.y +++ b/ntpd/ntp_parser.y @@ -100,6 +100,7 @@ %token T_Double /* not a token */ %token T_Driftfile %token T_Drop +%token T_Dscp %token T_Ellipsis /* "..." not "ellipsis" */ %token T_Enable %token T_End @@ -299,6 +300,7 @@ %type log_config_command %type log_config_list %type misc_cmd_dbl_keyword +%type misc_cmd_int_keyword %type misc_cmd_str_keyword %type misc_cmd_str_lcl_keyword %type mru_option @@ -1130,6 +1132,13 @@ miscellaneous_command av = create_attr_dval($1, $2); APPEND_G_FIFO(cfgt.vars, av); } + | misc_cmd_int_keyword T_Integer + { + attr_val *av; + + av = create_attr_ival($1, $2); + APPEND_G_FIFO(cfgt.vars, av); + } | misc_cmd_str_keyword T_String { attr_val *av; @@ -1199,6 +1208,10 @@ misc_cmd_dbl_keyword | T_Tick ; +misc_cmd_int_keyword + : T_Dscp + ; + misc_cmd_str_keyword : T_Ident | T_Leapfile