View | Details | Raw Unified | Return to bug 634
Collapse All | Expand All

(-)unbound-1.5.1-rga/services/listen_dnsport.c (-16 / +33 lines)
 Lines 368-397    Link Here 
368
 * (and also uses the interface mtu to determine the size of the packets).
368
 * (and also uses the interface mtu to determine the size of the packets).
369
 * So there won't be any EMSGSIZE error.  Against DNS fragmentation attacks.
369
 * So there won't be any EMSGSIZE error.  Against DNS fragmentation attacks.
370
 * FreeBSD already has same semantics without setting the option. */
370
 * FreeBSD already has same semantics without setting the option. */
371
#    if defined(IP_PMTUDISC_OMIT)
371
                int omit_set = 0;
372
#   if defined(IP_PMTUDISC_OMIT)
372
		int action = IP_PMTUDISC_OMIT;
373
		int action = IP_PMTUDISC_OMIT;
373
#    else
374
		int action = IP_PMTUDISC_DONT;
375
#    endif
376
		if (setsockopt(s, IPPROTO_IP, IP_MTU_DISCOVER,
374
		if (setsockopt(s, IPPROTO_IP, IP_MTU_DISCOVER,
377
			&action, (socklen_t)sizeof(action)) < 0) {
375
			&action, (socklen_t)sizeof(action)) < 0) {
378
			log_err("setsockopt(..., IP_MTU_DISCOVER, "
376
379
#    if defined(IP_PMTUDISC_OMIT)
377
                        if (errno != EINVAL) {
380
				"IP_PMTUDISC_OMIT"
378
                                log_err("setsockopt(..., IP_MTU_DISCOVER, IP_PMTUDISC_OMIT...) failed: %s",
379
				        strerror(errno));
380
381
#    ifndef USE_WINSOCK
382
			        close(s);
381
#    else
383
#    else
382
				"IP_PMTUDISC_DONT"
384
                                closesocket(s);
383
#    endif
385
#    endif
384
				"...) failed: %s",
386
                                *noproto = 0;
385
				strerror(errno));
387
                                *inuse = 0;
388
                                return -1;
389
                        }
390
		}
391
                else
392
                {
393
                    omit_set = 1;
394
                }
395
#   endif
396
                if (omit_set == 0) {
397
   		        int action = IP_PMTUDISC_DONT;
398
                        if (setsockopt(s, IPPROTO_IP, IP_MTU_DISCOVER,
399
                                &action, (socklen_t)sizeof(action)) < 0) {
400
                                log_err("setsockopt(..., IP_MTU_DISCOVER, IP_PMTUDISC_DONT...) failed: %s",
401
                                        strerror(errno));
386
#    ifndef USE_WINSOCK
402
#    ifndef USE_WINSOCK
387
			close(s);
403
			        close(s);
388
#    else
404
#    else
389
			closesocket(s);
405
			        closesocket(s);
390
#    endif
406
#    endif
391
			*noproto = 0;
407
			        *noproto = 0;
392
			*inuse = 0;
408
			        *inuse = 0;
393
			return -1;
409
			        return -1;
394
		}
410
		        }
411
                }
395
#  elif defined(IP_DONTFRAG)
412
#  elif defined(IP_DONTFRAG)
396
		int off = 0;
413
		int off = 0;
397
		if (setsockopt(s, IPPROTO_IP, IP_DONTFRAG,
414
		if (setsockopt(s, IPPROTO_IP, IP_DONTFRAG,

Return to bug 634