@@ -2887,6 +2887,7 @@ dns_build_ptr_answer(
2887
2887
}
2888
2888
2889
2889
#define DNS_RCODE_SERVER_REFUSE 0x5
2890
+ #define DNS_QUERY_TYPE_CLASS_LEN (2 * sizeof(ovs_be16))
2890
2891
2891
2892
/* Called with in the pinctrl_handler thread context. */
2892
2893
static void
@@ -2950,18 +2951,13 @@ pinctrl_handle_dns_lookup(
2950
2951
goto exit ;
2951
2952
}
2952
2953
2953
- /* Check if there is an additional record present, which is unsupported */
2954
- if (in_dns_header -> arcount ) {
2955
- VLOG_DBG_RL (& rl , "Received DNS query with additional records, which"
2956
- " is unsupported" );
2957
- goto exit ;
2958
- }
2959
-
2960
2954
struct udp_header * in_udp = dp_packet_l4 (pkt_in );
2961
2955
size_t udp_len = ntohs (in_udp -> udp_len );
2962
2956
size_t l4_len = dp_packet_l4_size (pkt_in );
2957
+ uint8_t * l4_start = (uint8_t * ) in_udp ;
2963
2958
uint8_t * end = (uint8_t * )in_udp + MIN (udp_len , l4_len );
2964
2959
uint8_t * in_dns_data = (uint8_t * )(in_dns_header + 1 );
2960
+ uint8_t * in_dns_data_start = in_dns_data ;
2965
2961
uint8_t * in_queryname = in_dns_data ;
2966
2962
uint16_t idx = 0 ;
2967
2963
struct ds query_name ;
@@ -2985,7 +2981,7 @@ pinctrl_handle_dns_lookup(
2985
2981
in_dns_data += idx ;
2986
2982
2987
2983
/* Query should have TYPE and CLASS fields */
2988
- if (in_dns_data + ( 2 * sizeof ( ovs_be16 )) > end ) {
2984
+ if (in_dns_data + DNS_QUERY_TYPE_CLASS_LEN > end ) {
2989
2985
ds_destroy (& query_name );
2990
2986
goto exit ;
2991
2987
}
@@ -2999,6 +2995,10 @@ pinctrl_handle_dns_lookup(
2999
2995
goto exit ;
3000
2996
}
3001
2997
2998
+ uint8_t * rest = in_dns_data + DNS_QUERY_TYPE_CLASS_LEN ;
2999
+ uint32_t query_size = rest - in_dns_data_start ;
3000
+ uint32_t query_l4_size = rest - l4_start ;
3001
+
3002
3002
uint64_t dp_key = ntohll (pin -> flow_metadata .flow .metadata );
3003
3003
const char * answer_data = NULL ;
3004
3004
bool ovn_owned = false;
@@ -3081,7 +3081,7 @@ pinctrl_handle_dns_lookup(
3081
3081
goto exit ;
3082
3082
}
3083
3083
3084
- uint16_t new_l4_size = ntohs ( in_udp -> udp_len ) + dns_answer .size ;
3084
+ uint16_t new_l4_size = query_l4_size + dns_answer .size ;
3085
3085
size_t new_packet_size = pkt_in -> l4_ofs + new_l4_size ;
3086
3086
struct dp_packet pkt_out ;
3087
3087
dp_packet_init (& pkt_out , new_packet_size );
@@ -3118,7 +3118,7 @@ pinctrl_handle_dns_lookup(
3118
3118
out_dns_header -> arcount = 0 ;
3119
3119
3120
3120
/* Copy the Query section. */
3121
- dp_packet_put (& pkt_out , dp_packet_data (pkt_in ), dp_packet_size ( pkt_in ) );
3121
+ dp_packet_put (& pkt_out , dp_packet_data (pkt_in ), query_size );
3122
3122
3123
3123
/* Copy the answer sections. */
3124
3124
dp_packet_put (& pkt_out , dns_answer .data , dns_answer .size );
0 commit comments