Blob Blame Raw
--- 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 ``<none>''.
    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);