From 7c5a8df542f26d168d2fed0b95062be690c10e9a Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Tue, 20 Apr 2010 13:34:14 +0000 Subject: [PATCH] - add support for QoS marked traffic (#576652) --- cyrus-imapd-2.3.15-qos.patch | 83 ++++++++++++++++++++++++++++++++++++ cyrus-imapd.imap-2.3.x-conf | 2 + cyrus-imapd.spec | 9 +++- 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 cyrus-imapd-2.3.15-qos.patch diff --git a/cyrus-imapd-2.3.15-qos.patch b/cyrus-imapd-2.3.15-qos.patch new file mode 100644 index 0000000..1bb28c8 --- /dev/null +++ b/cyrus-imapd-2.3.15-qos.patch @@ -0,0 +1,83 @@ +--- cyrus-imapd-2.3.15/lib/imapoptions.orig 2009-06-29 10:21:06.000000000 -0700 ++++ cyrus-imapd-2.3.15/lib/imapoptions 2009-12-14 13:40:56.000000000 -0800 +@@ -854,6 +854,10 @@ are listed with ``''. + strip the default realm from the userid (this does not affect the stripping + of realms specified by the afspts_localrealms option) */ + ++{ "qosmarking", "cs0", ENUM("cs0", "cs1", "cs2", "cs3", "cs4", "cs5", "cs6", "cs7", "af11", "af12", "af13", "af21", "af22", "af23", "af31", "af32", "af33", "af41", "af42", "af43", "ef") } ++/* This specifies the Class Selector or Differentiated Services Code Point ++ designation on IP headers (in the ToS field). */ ++ + { "quota_db", "quotalegacy", STRINGLIST("flat", "berkeley", "berkeley-hash", "skiplist", "sql", "quotalegacy")} + /* The cyrusdb backend to use for quotas. */ + +--- cyrus-imapd-2.3.15/lib/libconfig.c.orig 2009-08-20 08:26:15.000000000 -0700 ++++ cyrus-imapd-2.3.15/lib/libconfig.c 2009-12-13 23:37:20.000000000 -0800 +@@ -82,6 +82,7 @@ enum enum_value config_virtdomains; + enum enum_value config_mupdate_config; /* IMAP_ENUM_MUPDATE_CONFIG_STANDARD */ + int config_maxword; + int config_maxquoted; ++int config_qosmarking; + + /* declared in each binary that uses libconfig */ + extern const int config_need_data; +@@ -210,11 +211,21 @@ static void config_ispartition(const cha + if (!strncmp("partition-", key, 10)) *found = 1; + } + ++static const unsigned char qos[] = { ++/* cs0..cs7 */ 0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0, ++/* af11..af13 */ 0x28, 0x30, 0x38, ++/* af21..af23 */ 0x48, 0x50, 0x58, ++/* af31..af33 */ 0x68, 0x70, 0x78, ++/* af41..af43 */ 0x88, 0x90, 0x98, ++/* ef */ 0xb8 ++}; ++ + void config_read(const char *alt_config) + { + enum imapopt opt = IMAPOPT_ZERO; + char buf[4096]; + char *p; ++ int ival; + + /* xxx this is leaked, this may be able to be better in 2.2 (cyrus_done) */ + if(alt_config) config_filename = xstrdup(alt_config); +@@ -328,6 +339,9 @@ void config_read(const char *alt_config) + /* set some limits */ + config_maxquoted = config_getint(IMAPOPT_MAXQUOTED); + config_maxword = config_getint(IMAPOPT_MAXWORD); ++ ++ ival = config_getenum(IMAPOPT_QOSMARKING); ++ config_qosmarking = qos[ival]; + } + + #define GROWSIZE 4096 +--- cyrus-imapd-2.3.15/lib/libconfig.h.orig 2008-09-23 10:34:38.000000000 -0700 ++++ cyrus-imapd-2.3.15/lib/libconfig.h 2009-12-13 23:19:40.000000000 -0800 +@@ -80,6 +80,7 @@ extern enum enum_value config_virtdomain + extern enum enum_value config_mupdate_config; + extern int config_maxquoted; + extern int config_maxword; ++extern int config_qosmarking; + + /* config requirement flags */ + #define CONFIG_NEED_PARTITION_DATA (1<<0) +--- cyrus-imapd-2.3.15/master/master.c.orig 2009-03-30 21:11:23.000000000 -0700 ++++ cyrus-imapd-2.3.15/master/master.c 2009-12-14 14:18:24.000000000 -0800 +@@ -439,6 +439,15 @@ void service_create(struct service *s) + } + #endif + ++ /* set IP ToS if supported */ ++#if defined(SOL_IP) && defined(IP_TOS) ++ r = setsockopt(s->socket, SOL_IP, IP_TOS, ++ (void *) &config_qosmarking, sizeof(config_qosmarking)); ++ if (r < 0) { ++ syslog(LOG_WARNING, "unable to setsocketopt(IP_TOS): %m"); ++ } ++#endif ++ + oldumask = umask((mode_t) 0); /* for linux */ + r = bind(s->socket, res->ai_addr, res->ai_addrlen); + umask(oldumask); diff --git a/cyrus-imapd.imap-2.3.x-conf b/cyrus-imapd.imap-2.3.x-conf index 2579793..23a7415 100644 --- a/cyrus-imapd.imap-2.3.x-conf +++ b/cyrus-imapd.imap-2.3.x-conf @@ -9,3 +9,5 @@ sasl_mech_list: PLAIN tls_cert_file: /etc/pki/cyrus-imapd/cyrus-imapd.pem tls_key_file: /etc/pki/cyrus-imapd/cyrus-imapd.pem tls_ca_file: /etc/pki/tls/certs/ca-bundle.crt +# uncomment this if you're operating in a DSCP environment (RFC-4594) +# qosmarking af13 diff --git a/cyrus-imapd.spec b/cyrus-imapd.spec index ba6301f..3d1d244 100644 --- a/cyrus-imapd.spec +++ b/cyrus-imapd.spec @@ -2,7 +2,7 @@ Name: cyrus-imapd Version: 2.3.16 -Release: 2%{?dist} +Release: 3%{?dist} %define ssl_pem_file %{_sysconfdir}/pki/%{name}/%{name}.pem @@ -62,6 +62,9 @@ Patch19: cyrus-imapd-2.3.12p2-current-db.patch # workaround, rhbz#553011 Patch20: cyrus-imapd-2.3.16-nodenny.patch +# from upstream, rhbz#576652, for cyrus-imapd < 2.4 +Patch21: cyrus-imapd-2.3.15-qos.patch + BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) BuildRequires: autoconf @@ -151,6 +154,7 @@ one running the server. %patch18 -p1 -b .krb4 %patch19 -p1 -b .db4.7 %patch20 -p1 -b .nodenny +%patch21 -p1 -b .qos # add additional sources mkdir doc/{m4,contrib} @@ -517,6 +521,9 @@ fi %{_mandir}/man1/* %changelog +* Tue Apr 20 2010 Michal Hlavinka - 2.3.16-3 +- add support for QoS marked traffic (#576652) + * Thu Jan 14 2010 Michal Hlavinka - 2.3.16-2 - ignore user_denny.db if missing (#553011) - fix location of certificates in default imapd.conf