Merge ~smoser/ubuntu/+source/resolvconf:bug/1675571-add-rc-prog into ~usd-import-team/ubuntu/+source/resolvconf:ubuntu/devel

Proposed by Scott Moser on 2017-03-28
Status: Needs review
Proposed branch: ~smoser/ubuntu/+source/resolvconf:bug/1675571-add-rc-prog
Merge into: ~usd-import-team/ubuntu/+source/resolvconf:ubuntu/devel
Diff against target: 126 lines (+44/-12)
6 files modified
debian/changelog (+10/-0)
debian/resolvconf.000resolvconf.if-up (+10/-5)
debian/resolvconf.000resolvconf.ppp.ip-down (+1/-1)
debian/resolvconf.000resolvconf.ppp.ip-up (+1/-1)
debian/resolvconf.resolvconf.if-down (+10/-5)
man/resolvconf.8 (+12/-0)
Reviewer Review Type Date Requested Status
Scott Moser Approve on 2017-03-30
Review via email: mp+321203@code.launchpad.net

Commit Message

allow setting of program name via dns-iface-name option in interfaces(5).

When ifupdown has multiple addresses for a given interface, integration
with resolvconf is broken. This is because resolvconf is called for each
stanza, but the scripts in /etc/network/if-*.d/ invoke
  resolvconf -a IFACE.PROG
or
  resolvconf -d IFACE.PROG
with IFACE being the interface name, and PROG set to ADDRFAM, where
ADDRFAM is only 'inet' or 'inet6'.

The solution here is to allow the author of interfaces(5) to provide
the program name via option 'dns-iface-name'.

As an example:
 auto eth0
 iface eth0 inet static
    address 138.197.98.102/20
    gateway 138.197.96.1
    dns-nameservers 8.8.8.8
    dns-iface-name public0

 iface eth0 inet static
    address 10.17.0.11/16
    dns-iface-name local

LP: #1675571

To post a comment you must log in.
Scott Moser (smoser) wrote :

Since it is resolvconf that adds the dns-* entries to interfaces,
a.) this should be adjusted to just use that namespace (change resolvconf-prog to dns-program-name)
b.) need to document this in man/resolvconf.8

Scott Moser (smoser) :
review: Needs Fixing
Scott Moser (smoser) wrote :

I addressed 'a' and 'b' above, but then realized that the dhclient script does not have access to the IF_* variables. so this does not work if any dhcp are used.

Scott Moser (smoser) wrote :

> I addressed 'a' and 'b' above, but then realized that the dhclient script does
> not have access to the IF_* variables. so this does not work if any dhcp are
> used.

Well, i was sort of right.
dhclient ends up using a resolvconf like the following
  ipv4: /sbin/resolvconf -a "${interface}.dhclient"
  ipv6: /sbin/resolvconf -a "${interface}.ip6.dhclient"

So it turns out that this will work. 'dhcp' or dhcpv6' stanzas will not overwrite any *non* dhcp stanzas, but you can't have 2 ipv4 or 2 ipv6 dhcp stanzas or *they* would fight.

Scott Moser (smoser) :
review: Approve
Scott Moser (smoser) wrote :

The other option for this is to not require the ENI author to put these variables in, but instead have ifupdown provide a consistent value that resolvconf could use. But that would have to be made consistent across changes to the file, deletes of interfaces or adds of interfaces in any order.

Ie, this has to work for any ordering of eth1 and eth0 or their multiple stanzas inside an ENI.

ifup eth1
ifup eth0
ifdown eth0
# edit ENI, remove eth1
ifup down eth0

Unmerged commits

257b73e... by Scott Moser on 2017-03-28

update changelog

5a54f58... by Scott Moser on 2017-03-28

allow setting of program name via dns-iface-name option in interfaces(5).

When ifupdown has multiple addresses for a given interface, integration
with resolvconf is broken. This is because resolvconf is called for each
stanza, but the scripts in /etc/network/if-*.d/ invoke
  resolvconf -a IFACE.PROG
or
  resolvconf -d IFACE.PROG
with IFACE being the interface name, and PROG set to ADDRFAM, where
ADDRFAM is only 'inet' or 'inet6'.

The solution here is to allow the author of interfaces(5) to provide
the program name via option 'dns-iface-name'.

As an example:
 auto eth0
 iface eth0 inet static
    address 138.197.98.102/20
    gateway 138.197.96.1
    dns-nameservers 8.8.8.8
    dns-iface-name public0

 iface eth0 inet static
    address 10.17.0.11/16
    dns-iface-name local

LP: #1675571

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index c02f413..92e04ae 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,13 @@
6+resolvconf (1.79ubuntu5) UNRELEASED; urgency=medium
7+
8+ * debian/resolvconf.*.if-{up,down}:
9+ allow setting of program name through the dns-iface-name option in
10+ interfaces(5). This allows users or tools to author interfaces
11+ so that multiple stanzas do not collide in their dns settings.
12+ (LP: #1675571)
13+
14+ -- Scott Moser <smoser@ubuntu.com> Tue, 28 Mar 2017 12:26:54 -0400
15+
16 resolvconf (1.79ubuntu4) zesty; urgency=medium
17
18 * debian/resolvconf.service: Add missing Wants=network-pre.target.
19diff --git a/debian/resolvconf.000resolvconf.if-up b/debian/resolvconf.000resolvconf.if-up
20index f799371..498c97e 100755
21--- a/debian/resolvconf.000resolvconf.if-up
22+++ b/debian/resolvconf.000resolvconf.if-up
23@@ -7,10 +7,15 @@
24
25 [ -x /sbin/resolvconf ] || exit 0
26
27-case "$ADDRFAM" in
28- inet|inet6) : ;;
29- *) exit 0 ;;
30-esac
31+if [ -n "${IF_DNS_IFACE_NAME}" ]; then
32+ IFACE_NAME="${IF_DNS_IFACE_NAME}"
33+else
34+ case "$ADDRFAM" in
35+ inet|inet6) : ;;
36+ *) exit 0 ;;
37+ esac
38+ IFACE_NAME="${IFACE}.${ADDRFAM}"
39+fi
40
41 R=""
42 if [ "$IF_DNS_DOMAIN" ] ; then
43@@ -43,5 +48,5 @@ for OPT in $IF_DNS_NAMESERVER ; do
44 done
45 IFS="$STANDARD_IFS"
46
47-echo -n "$R" | /sbin/resolvconf -a "${IFACE}.${ADDRFAM}" || :
48+echo -n "$R" | /sbin/resolvconf -a "${IFACE_NAME}" || :
49
50diff --git a/debian/resolvconf.000resolvconf.ppp.ip-down b/debian/resolvconf.000resolvconf.ppp.ip-down
51index 561ef41..a0458fd 100755
52--- a/debian/resolvconf.000resolvconf.ppp.ip-down
53+++ b/debian/resolvconf.000resolvconf.ppp.ip-down
54@@ -17,5 +17,5 @@ case "$6" in
55 ;;
56 esac
57
58-/sbin/resolvconf -d "${PPP_IFACE}.pppd"
59+/sbin/resolvconf -d "${IF_DNS_IFACE_NAME:-${PPP_IFACE}.pppd}"
60
61diff --git a/debian/resolvconf.000resolvconf.ppp.ip-up b/debian/resolvconf.000resolvconf.ppp.ip-up
62index c83ea18..5090123 100755
63--- a/debian/resolvconf.000resolvconf.ppp.ip-up
64+++ b/debian/resolvconf.000resolvconf.ppp.ip-up
65@@ -29,5 +29,5 @@ if [ "$DNS2" ] ; then
66 "
67 fi
68
69-echo -n "$R" | /sbin/resolvconf -a "${PPP_IFACE}.pppd"
70+echo -n "$R" | /sbin/resolvconf -a "${IF_DNS_IFACE_NAME:-${PPP_IFACE}.pppd}"
71
72diff --git a/debian/resolvconf.resolvconf.if-down b/debian/resolvconf.resolvconf.if-down
73index 66e3a9f..1883261 100755
74--- a/debian/resolvconf.resolvconf.if-down
75+++ b/debian/resolvconf.resolvconf.if-down
76@@ -7,10 +7,15 @@
77
78 [ -x /sbin/resolvconf ] || exit 0
79
80-case "$ADDRFAM" in
81- inet|inet6) : ;;
82- *) exit 0 ;;
83-esac
84+if [ -n "${IF_DNS_IFACE_NAME}" ]; then
85+ IFACE_NAME="${IF_DNS_IFACE_NAME}"
86+else
87+ case "$ADDRFAM" in
88+ inet|inet6) : ;;
89+ *) exit 0 ;;
90+ esac
91+ IFACE_NAME="${IFACE}.${ADDRFAM}"
92+fi
93
94-/sbin/resolvconf -d "${IFACE}.${ADDRFAM}" || :
95+/sbin/resolvconf -d "${IFACE_NAME}" || :
96
97diff --git a/man/resolvconf.8 b/man/resolvconf.8
98index fd4b417..f29e7ce 100644
99--- a/man/resolvconf.8
100+++ b/man/resolvconf.8
101@@ -114,6 +114,17 @@ option is also accepted and, unlike
102 can be given multiple arguments,
103 separated by spaces.
104 .PP
105+The
106+.B dns-iface-name
107+option controls what interface name will be given to resolvconf
108+when it is invoked by the
109+.IR ifup.d
110+or
111+.IR ifdown.d
112+scripts. No value is required. The default depends
113+on how the device is configured. This is useful if you have multiple
114+addresses configured for a single device with separate stanzas.
115+.PP
116 The
117 .B dns\-domain
118 option is deprecated in favor of
119@@ -130,6 +141,7 @@ The resulting stanza might look like the following example.
120 dns\-nameserver 192.168.1.254
121 dns\-nameserver 8.8.8.8
122 dns\-search foo.org bar.com
123+ dns\-iface\-name eth0.foobar
124 .EE
125 .PP
126 N.B.: On a machine where resolvconf

Subscribers

People subscribed via source and target branches