summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl
diff options
context:
space:
mode:
authorVladislav Grishenko <themiron@mail.ru>2019-02-02 22:58:48 +0500
committerVladislav Grishenko <themiron@mail.ru>2019-02-02 22:58:48 +0500
commit185c2b5d40443c47c82bf90ac016129fa7329f4c (patch)
tree0056e4024c24ad5ca16e27a9d647d2f5255825b4 /accel-pppd/ctrl
parentf61d4a5aec11dfda73700c19df9a7662f8a10988 (diff)
downloadaccel-ppp-185c2b5d40443c47c82bf90ac016129fa7329f4c.tar.gz
accel-ppp-185c2b5d40443c47c82bf90ac016129fa7329f4c.zip
ipoe: dhcpv4: fix dhcp reply with dns1 unset, dns2 set
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r--accel-pppd/ctrl/ipoe/dhcpv4.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.c b/accel-pppd/ctrl/ipoe/dhcpv4.c
index a8b306b..6c97bc8 100644
--- a/accel-pppd/ctrl/ipoe/dhcpv4.c
+++ b/accel-pppd/ctrl/ipoe/dhcpv4.c
@@ -693,13 +693,10 @@ static inline int dhcpv4_packet_add_opt_u32(struct dhcpv4_packet *pack, int type
int dhcpv4_send_reply(int msg_type, struct dhcpv4_serv *serv, struct dhcpv4_packet *req, uint32_t yiaddr, uint32_t siaddr, uint32_t router, uint32_t mask, int lease_time, int renew_time, struct dhcpv4_packet *relay)
{
struct dhcpv4_packet *pack;
- int val, r;
- struct dns {
- in_addr_t dns1;
- in_addr_t dns2;
- } dns;
- int dns_avail = 0;
struct dhcpv4_option *opt;
+ in_addr_t addr[2];
+ int dns_avail = 0;
+ int val, r;
pack = dhcpv4_packet_alloc();
if (!pack) {
@@ -743,7 +740,7 @@ int dhcpv4_send_reply(int msg_type, struct dhcpv4_serv *serv, struct dhcpv4_pack
list_for_each_entry(opt, &relay->options, entry) {
if (opt->type == 53 || opt->type == 54 || opt->type == 51 || opt->type == 58 || opt->type == 1 || (opt->type == 3 && router))
continue;
- if (opt->type == 6)
+ else if (opt->type == 6)
dns_avail = 1;
if (dhcpv4_packet_add_opt(pack, opt->type, opt->data, opt->len))
goto out_err;
@@ -751,15 +748,12 @@ int dhcpv4_send_reply(int msg_type, struct dhcpv4_serv *serv, struct dhcpv4_pack
}
if (!dns_avail) {
- if (conf_dns1 && conf_dns2) {
- dns.dns1 = conf_dns1;
- dns.dns2 = conf_dns2;
- if (dhcpv4_packet_add_opt(pack, 6, &dns, 8))
- goto out_err;
- } else if (conf_dns1) {
- if (dhcpv4_packet_add_opt(pack, 6, &conf_dns1, 4))
- goto out_err;
- }
+ if (conf_dns1)
+ addr[dns_avail++] = conf_dns1;
+ if (conf_dns2)
+ addr[dns_avail++] = conf_dns2;
+ if (dns_avail && dhcpv4_packet_add_opt(pack, 6, addr, dns_avail * sizeof(addr[0])))
+ goto out_err;
}
*pack->ptr++ = 255;