]> git.pld-linux.org Git - packages/dhcp.git/blob - dhcp-ppp.patch
- updated to 4.4.3, more patches from Fedora
[packages/dhcp.git] / dhcp-ppp.patch
1 From fe89d58ea8627c66feffa81997daa024834eeb15 Mon Sep 17 00:00:00 2001
2 From: Pavel Zhukov <pzhukov@redhat.com>
3 Date: Thu, 21 Feb 2019 10:33:06 +0100
4 Subject: [PATCH 13/28] DHCPv6 over PPP support (#626514)
5
6 ---
7  client/dhc6.c     |  3 ++-
8  client/dhclient.c | 17 ++++++++++++++---
9  common/bpf.c      | 16 ++++++++++++++++
10  common/lpf.c      | 16 ++++++++++++++++
11  includes/dhcp.h   |  2 ++
12  includes/dhcpd.h  |  2 +-
13  server/dhcpv6.c   |  3 +++
14  7 files changed, 54 insertions(+), 5 deletions(-)
15
16 diff --git a/client/dhc6.c b/client/dhc6.c
17 index 35cf3d0..88fd07d 100644
18 --- a/client/dhc6.c
19 +++ b/client/dhc6.c
20 @@ -5737,7 +5737,8 @@ make_client6_options(struct client_state *client, struct option_state **op,
21          */
22         if ((oc = lookup_option(&dhcpv6_universe, *op,
23                                 D6O_CLIENTID)) == NULL) {
24 -               if (!option_cache(&oc, &default_duid, NULL, clientid_option,
25 +               if (default_duid.len == 0 ||
26 +                   !option_cache(&oc, &default_duid, NULL, clientid_option,
27                                   MDL))
28                         log_fatal("Failure assembling a DUID.");
29  
30 diff --git a/client/dhclient.c b/client/dhclient.c
31 index b49fcb3..a99e21f 100644
32 --- a/client/dhclient.c
33 +++ b/client/dhclient.c
34 @@ -1223,8 +1223,8 @@ main(int argc, char **argv) {
35                         if (default_duid.buffer != NULL)
36                                 data_string_forget(&default_duid, MDL);
37  
38 -                       form_duid(&default_duid, MDL);
39 -                       write_duid(&default_duid);
40 +                       if (form_duid(&default_duid, MDL) == ISC_R_SUCCESS)
41 +                               write_duid(&default_duid);
42                 }
43         }
44  
45 @@ -4202,7 +4202,7 @@ write_options(struct client_state *client, struct option_state *options,
46   * is not how it is intended.  Upcoming rearchitecting the client should
47   * address this "one daemon model."
48   */
49 -void
50 +isc_result_t
51  form_duid(struct data_string *duid, const char *file, int line)
52  {
53         struct interface_info *ip;
54 @@ -4215,6 +4215,15 @@ form_duid(struct data_string *duid, const char *file, int line)
55         if (ip == NULL)
56                 log_fatal("Impossible condition at %s:%d.", MDL);
57  
58 +       while (ip && ip->hw_address.hbuf[0] == HTYPE_RESERVED) {
59 +               /* Try the other interfaces */
60 +               log_debug("Cannot form default DUID from interface %s.", ip->name);
61 +               ip = ip->next;
62 +       }
63 +       if (ip == NULL) {
64 +               return ISC_R_UNEXPECTED;
65 +       }
66 +
67         if ((ip->hw_address.hlen == 0) ||
68             (ip->hw_address.hlen > sizeof(ip->hw_address.hbuf)))
69                 log_fatal("Impossible hardware address length at %s:%d.", MDL);
70 @@ -4260,6 +4269,8 @@ form_duid(struct data_string *duid, const char *file, int line)
71                 log_info("Created duid %s.", str);
72                 dfree(str, MDL);
73         }
74 +       
75 +       return ISC_R_SUCCESS;
76  }
77  
78  /* Write the default DUID to the lease store. */
79 diff --git a/common/bpf.c b/common/bpf.c
80 index d2a0549..aede242 100644
81 --- a/common/bpf.c
82 +++ b/common/bpf.c
83 @@ -650,6 +650,22 @@ get_hw_addr(const char *name, struct hardware *hw) {
84                          memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
85                          break;
86  #endif /* IFT_FDDI */
87 +#if defined(IFT_PPP)
88 +                case IFT_PPP:
89 +                        if (local_family != AF_INET6)
90 +                             log_fatal("Unsupported device type %d for \"%s\"",
91 +                                        sa->sdl_type, name);
92 +                        hw->hlen = 0;
93 +                        hw->hbuf[0] = HTYPE_RESERVED;
94 +                        /* 0xdeadbeef should never occur on the wire,
95 +                         *  and is a signature that something went wrong.
96 +                         */
97 +                        hw->hbuf[1] = 0xde;
98 +                        hw->hbuf[2] = 0xad;
99 +                        hw->hbuf[3] = 0xbe;
100 +                        hw->hbuf[4] = 0xef;
101 +                        break;
102 +#endif
103                  default:
104                          log_fatal("Unsupported device type %d for \"%s\"",
105                                    sa->sdl_type, name);
106 diff --git a/common/lpf.c b/common/lpf.c
107 index bd20b3f..bb8822a 100644
108 --- a/common/lpf.c
109 +++ b/common/lpf.c
110 @@ -563,6 +563,22 @@ get_hw_addr(const char *name, struct hardware *hw) {
111                         hw->hbuf[0] = HTYPE_FDDI;
112                         memcpy(&hw->hbuf[1], sa->sa_data, 6);
113                         break;
114 +#if defined(ARPHRD_PPP)
115 +               case ARPHRD_PPP:
116 +                       if (local_family != AF_INET6)
117 +                               log_fatal("Unsupported device type %d for \"%s\"",
118 +                                          sa->sa_family, name);
119 +                       hw->hlen = 0;
120 +                       hw->hbuf[0] = HTYPE_RESERVED;
121 +                       /* 0xdeadbeef should never occur on the wire,
122 +                        * and is a signature that something went wrong.
123 +                        */
124 +                       hw->hbuf[1] = 0xde;
125 +                       hw->hbuf[2] = 0xad;
126 +                       hw->hbuf[3] = 0xbe;
127 +                       hw->hbuf[4] = 0xef;
128 +                       break;
129 +#endif
130                 default:
131                         log_fatal("Unsupported device type %ld for \"%s\"",
132                                   (long int)sa->sa_family, name);
133 diff --git a/includes/dhcp.h b/includes/dhcp.h
134 index 5a73129..7202f1d 100644
135 --- a/includes/dhcp.h
136 +++ b/includes/dhcp.h
137 @@ -80,6 +80,8 @@ struct dhcp_packet {
138                                          * is no standard for this so we
139                                          * just steal a type            */
140  
141 +#define HTYPE_RESERVED 0               /* RFC 5494 */
142 +
143  /* Magic cookie validating dhcp options field (and bootp vendor
144     extensions field). */
145  #define DHCP_OPTIONS_COOKIE    "\143\202\123\143"
146 diff --git a/includes/dhcpd.h b/includes/dhcpd.h
147 index 25e1c72..4c5e877 100644
148 --- a/includes/dhcpd.h
149 +++ b/includes/dhcpd.h
150 @@ -3071,7 +3071,7 @@ void client_dns_remove(struct client_state *client, struct iaddr *addr);
151  
152  void dhcpv4_client_assignments(void);
153  void dhcpv6_client_assignments(void);
154 -void form_duid(struct data_string *duid, const char *file, int line);
155 +isc_result_t form_duid(struct data_string *duid, const char *file, int line);
156  
157  void dhcp4o6_start(void);
158  
159 diff --git a/server/dhcpv6.c b/server/dhcpv6.c
160 index 0ea0532..7d61dc5 100644
161 --- a/server/dhcpv6.c
162 +++ b/server/dhcpv6.c
163 @@ -482,6 +482,9 @@ generate_new_server_duid(void) {
164                 if (p->hw_address.hlen > 0) {
165                         break;
166                 }
167 +               if (p->next == NULL && p->hw_address.hbuf[0] == HTYPE_RESERVED) {
168 +                       log_error("Can not generate DUID from interfaces which do not have hardware addresses, please configure server-duid!");
169 +               }
170         }
171         if (p == NULL) {
172                 return ISC_R_UNEXPECTED;
173 -- 
174 2.35.1
175
This page took 0.202836 seconds and 3 git commands to generate.