Select Git revision
0030-dnsmasq-add-patch-to-allow-setting-the-default-packet-mark.patch
Forked from
firmware / FFS Gluon
Source project has a limited visibility.
0030-dnsmasq-add-patch-to-allow-setting-the-default-packet-mark.patch 3.71 KiB
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Sun, 6 Jul 2014 08:12:35 +0200
Subject: dnsmasq: add patch to allow setting the default packet mark
diff --git a/package/dnsmasq/patches/901-packet-mark.patch b/package/dnsmasq/patches/901-packet-mark.patch
new file mode 100644
index 0000000..286af3a
--- /dev/null
+++ b/package/dnsmasq/patches/901-packet-mark.patch
@@ -0,0 +1,103 @@
+--- a/src/dnsmasq.h
++++ b/src/dnsmasq.h
+@@ -802,6 +802,7 @@ extern struct daemon {
+ int cachesize, ftabsize;
+ int port, query_port, min_port;
+ unsigned long local_ttl, neg_ttl, max_ttl, max_cache_ttl, auth_ttl;
++ unsigned int packet_mark;
+ struct hostsfile *addn_hosts;
+ struct dhcp_context *dhcp, *dhcp6;
+ struct dhcp_config *dhcp_conf;
+--- a/src/forward.c
++++ b/src/forward.c
+@@ -366,17 +366,17 @@ static int forward_query(int udpfd, unio
+ daemon->rfd_save = forward->rfd4;
+ fd = forward->rfd4->fd;
+ }
++ }
++
++ unsigned int mark = daemon->packet_mark;
+
+ #ifdef HAVE_CONNTRACK
+- /* Copy connection mark of incoming query to outgoing connection. */
+- if (option_bool(OPT_CONNTRACK))
+- {
+- unsigned int mark;
+- if (get_incoming_mark(udpaddr, dst_addr, 0, &mark))
+- setsockopt(fd, SOL_SOCKET, SO_MARK, &mark, sizeof(unsigned int));
+- }
++ /* Copy connection mark of incoming query to outgoing connection. */
++ if (option_bool(OPT_CONNTRACK))
++ get_incoming_mark(udpaddr, dst_addr, 0, &mark);
+ #endif
+- }
++
++ setsockopt(fd, SOL_SOCKET, SO_MARK, &mark, sizeof(unsigned int));
+
+ if (sendto(fd, (char *)header, plen, 0,
+ &start->addr.sa,
+@@ -1001,11 +1001,11 @@ unsigned char *tcp_request(int confd, ti
+ continue;
+ }
+
++ unsigned int mark = daemon->packet_mark;
+ #ifdef HAVE_CONNTRACK
+ /* Copy connection mark of incoming query to outgoing connection. */
+ if (option_bool(OPT_CONNTRACK))
+ {
+- unsigned int mark;
+ struct all_addr local;
+ #ifdef HAVE_IPV6
+ if (local_addr->sa.sa_family == AF_INET6)
+@@ -1014,10 +1014,11 @@ unsigned char *tcp_request(int confd, ti
+ #endif
+ local.addr.addr4 = local_addr->in.sin_addr;
+
+- if (get_incoming_mark(&peer_addr, &local, 1, &mark))
+- setsockopt(last_server->tcpfd, SOL_SOCKET, SO_MARK, &mark, sizeof(unsigned int));
++ get_incoming_mark(&peer_addr, &local, 1, &mark);
+ }
+ #endif