From 36a3ae5f08725242b1fb4dfecc5617cc9c3e971b Mon Sep 17 00:00:00 2001 From: Phil Pennock Date: Sat, 2 Jun 2012 09:10:44 -0400 Subject: [PATCH] DSCP: document; hex print; -bI:dscp --- doc/doc-docbook/spec.xfpt | 23 +++++++++++++++++++ doc/doc-txt/ChangeLog | 2 ++ doc/doc-txt/NewStuff | 5 +++++ doc/doc-txt/OptionLists.txt | 1 + src/src/exim.c | 12 ++++++++-- src/src/functions.h | 1 + src/src/ip.c | 44 ++++++++++++++++++++++--------------- src/src/smtp_out.c | 2 +- 8 files changed, 69 insertions(+), 21 deletions(-) diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt index 64aac1ae5..15a8f3550 100644 --- a/doc/doc-docbook/spec.xfpt +++ b/doc/doc-docbook/spec.xfpt @@ -2938,6 +2938,7 @@ if this is required. If the &%bi_command%& option is not set, calling Exim with &%-bi%& is a no-op. .new +. // Keep :help first, then the rest in alphabetical order .vitem &%-bI:help%& .oindex "&%-bI:help%&" .cindex "querying exim information" @@ -2947,6 +2948,12 @@ consumption. This one is not. The &%-bI:help%& option asks Exim for a synopsis of supported options beginning &`-bI:`&. Use of any of these options shall cause Exim to exit after producing the requested output. +.vitem &%-bI:dscp%& +.oindex "&%-bI:dscp%&" +.cindex "DSCP" "values" +This option causes Exim to emit an alphabetically sorted list of all +recognised DSCP names. + .vitem &%-bI:sieve%& .oindex "&%-bI:sieve%&" .cindex "Sieve filter" "capabilities" @@ -22094,6 +22101,22 @@ See the &%search_parents%& option in chapter &<>& for more details. +.new +.option dscp smtp string unset +.cindex "DCSP" +.cindex "DiffServ" +This option causes the DSCP value associated with a socket to be set to one +of a number of fixed strings. The &%-bI:dscp%& option may be used to ask +Exim which values it knows of. Common values include &`throughput`&, +&`mincost`&, and on newer systems &`ef`&, &`af41`&, ... + +The outbound packets from Exim will be marked with this value in the header +(for IPv4, the TOS field; for IPv6, the TCLASS field); there is no guarantee +that these packets will have any effect, not be stripped by networking +equipment, or do much of anything without cooperation with your Network +Engineer and those of all network operators between the source and destination. +.wen + .option fallback_hosts smtp "string list" unset .cindex "fallback" "hosts specified on transport" diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 34f940592..1e8063bf3 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -16,6 +16,8 @@ PP/04 First step towards DNSSEC, provide $sender_host_dnssec for $sender_host_name and config options to manage this, and basic check routines. +PP/05 DSCP support for outbound connections. + Exim version 4.80 ----------------- diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff index 093feee72..2aaf56232 100644 --- a/doc/doc-txt/NewStuff +++ b/doc/doc-txt/NewStuff @@ -39,6 +39,11 @@ Version 4.81 Current status: work-in-progress; $sender_host_dnssec variable added. + 5. DSCP support for outbound connections: on a transport using the smtp driver, + set "dscp = ef", for instance, to cause the connections to have the relevant + DSCP (IPv4 TOS or IPv6 TCLASS) value in the header. Supported values depend + upon system libraries. "exim -bI:dscp" to list the ones Exim knows of. + Version 4.80 ------------ diff --git a/doc/doc-txt/OptionLists.txt b/doc/doc-txt/OptionLists.txt index 20d8dbdc5..1c7881e76 100644 --- a/doc/doc-txt/OptionLists.txt +++ b/doc/doc-txt/OptionLists.txt @@ -187,6 +187,7 @@ driver string unset authenticator unset routers 4.00 unset transports drop_cr boolean false main 4.00 became a no-op in 4.21 +dscp string unset smtp 4.81 dsn_from string* + main 4.67 envelope_to_add boolean false transports envelope_to_remove boolean true main diff --git a/src/src/exim.c b/src/src/exim.c index 9f6f3d8c3..d20f938e6 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -57,7 +57,7 @@ store_free(block); *************************************************/ enum commandline_info { CMDINFO_NONE=0, - CMDINFO_HELP, CMDINFO_SIEVE }; + CMDINFO_HELP, CMDINFO_SIEVE, CMDINFO_DSCP }; @@ -1044,6 +1044,7 @@ switch(request) "If the string is not recognised, you'll get this help (on stderr).\n" "\n" " exim -bI:help this information\n" +" exim -bI:dscp dscp value keywords known\n" " exim -bI:sieve list of supported sieve extensions, one per line.\n" ); return; @@ -1051,7 +1052,9 @@ switch(request) for (pp = exim_sieve_extension_list; *pp; ++pp) fprintf(stream, "%s\n", *pp); return; - + case CMDINFO_DSCP: + dscp_list_to_stream(stream); + return; } } @@ -1987,6 +1990,11 @@ for (i = 1; i < argc; i++) info_flag = CMDINFO_SIEVE; info_stdout = TRUE; } + else if (strcmpic(p, CUS"dscp") == 0) + { + info_flag = CMDINFO_DSCP; + info_stdout = TRUE; + } else if (strcmpic(p, CUS"help") == 0) { info_stdout = TRUE; diff --git a/src/src/functions.h b/src/src/functions.h index dd9549b18..7fea6ff5c 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -109,6 +109,7 @@ extern int dns_lookup(dns_answer *, uschar *, int, uschar **); extern int dns_special_lookup(dns_answer *, uschar *, int, uschar **); extern dns_record *dns_next_rr(dns_answer *, dns_scan *, int); extern uschar *dns_text_type(int); +extern void dscp_list_to_stream(FILE *); extern BOOL dscp_lookup(const uschar *, int, int *, int *, int *); extern void enq_end(uschar *); diff --git a/src/src/ip.c b/src/src/ip.c index 66a750dfd..be4511dfa 100644 --- a/src/src/ip.c +++ b/src/src/ip.c @@ -372,29 +372,29 @@ struct dscp_name_tableentry { /* Keep both of these tables sorted! */ static struct dscp_name_tableentry dscp_table[] = { #ifdef IPTOS_DSCP_AF11 - { "af11", IPTOS_DSCP_AF11 }, - { "af12", IPTOS_DSCP_AF12 }, - { "af13", IPTOS_DSCP_AF13 }, - { "af21", IPTOS_DSCP_AF21 }, - { "af22", IPTOS_DSCP_AF22 }, - { "af23", IPTOS_DSCP_AF23 }, - { "af31", IPTOS_DSCP_AF31 }, - { "af32", IPTOS_DSCP_AF32 }, - { "af33", IPTOS_DSCP_AF33 }, - { "af41", IPTOS_DSCP_AF41 }, - { "af42", IPTOS_DSCP_AF42 }, - { "af43", IPTOS_DSCP_AF43 }, - { "ef", IPTOS_DSCP_EF }, + { CUS"af11", IPTOS_DSCP_AF11 }, + { CUS"af12", IPTOS_DSCP_AF12 }, + { CUS"af13", IPTOS_DSCP_AF13 }, + { CUS"af21", IPTOS_DSCP_AF21 }, + { CUS"af22", IPTOS_DSCP_AF22 }, + { CUS"af23", IPTOS_DSCP_AF23 }, + { CUS"af31", IPTOS_DSCP_AF31 }, + { CUS"af32", IPTOS_DSCP_AF32 }, + { CUS"af33", IPTOS_DSCP_AF33 }, + { CUS"af41", IPTOS_DSCP_AF41 }, + { CUS"af42", IPTOS_DSCP_AF42 }, + { CUS"af43", IPTOS_DSCP_AF43 }, + { CUS"ef", IPTOS_DSCP_EF }, #endif #ifdef IPTOS_LOWCOST - { "lowcost", IPTOS_LOWCOST }, + { CUS"lowcost", IPTOS_LOWCOST }, #endif - { "lowdelay", IPTOS_LOWDELAY }, + { CUS"lowdelay", IPTOS_LOWDELAY }, #ifdef IPTOS_MINCOST - { "mincost", IPTOS_MINCOST }, + { CUS"mincost", IPTOS_MINCOST }, #endif - { "reliability", IPTOS_RELIABILITY }, - { "throughput", IPTOS_THROUGHPUT } + { CUS"reliability", IPTOS_RELIABILITY }, + { CUS"throughput", IPTOS_THROUGHPUT } }; static int dscp_table_size = sizeof(dscp_table) / sizeof(struct dscp_name_tableentry); @@ -468,5 +468,13 @@ while (last > first) return FALSE; } +void +dscp_list_to_stream(FILE *stream) +{ +int i; +for (i=0; i < dscp_table_size; ++i) + fprintf(stream, "%s\n", dscp_table[i].name); +} + /* End of ip.c */ diff --git a/src/src/smtp_out.c b/src/src/smtp_out.c index 7b58b4a74..42a889aa6 100644 --- a/src/src/smtp_out.c +++ b/src/src/smtp_out.c @@ -212,7 +212,7 @@ bomb out, just log it and continue in default traffic class. */ if (dscp && dscp_lookup(dscp, host_af, &dscp_level, &dscp_option, &dscp_value)) { HDEBUG(D_transport|D_acl|D_v) - debug_printf("DSCP \"%s\"=%d ", dscp, dscp_value); + debug_printf("DSCP \"%s\"=%x ", dscp, dscp_value); if (setsockopt(sock, dscp_level, dscp_option, &dscp_value, sizeof(dscp_value)) < 0) HDEBUG(D_transport|D_acl|D_v) debug_printf("failed to set DSCP: %s ", strerror(errno)); -- 2.30.2