About this list Date view Thread view Subject view Author view Attachment view

From: Sam Vilain (sam_at_vilain.net)
Date: Wed 30 Jul 2003 - 13:58:11 BST


Without understanding what this patch does ;-) I thought it made more
sense going here, and adding 2 rather than one to the score:

@@ -218,10 +233,10 @@
         struct sock *sk, *result = NULL;
         unsigned short hnum = ntohs(dport);
         int badness = -1;
+ int score;

         for(sk = udp_hash[hnum & (UDP_HTABLE_SIZE - 1)]; sk != NULL; sk =
sk->next) {
                 if(sk->num == hnum && !ipv6_only_sock(sk)) {
- int score;
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
                         score = sk->family == PF_INET ? 1 : 0;
 #else
@@ -231,7 +246,13 @@
                                 if(sk->rcv_saddr != daddr)
                                         continue;
                                 score+=2;
- }
+ }else if (sk->ip_info != NULL){
+ if (udp_in_list (sk->ip_info,daddr)){
+ score+=2;
+ }else{
+ continue;
+ }
+ }
                         if(sk->daddr) {
                                 if(sk->daddr != saddr)
                                         continue;

It looks like Marcel's rolling in a lot of fixes from Alan's tree.
I've come up against this one from about 2.4.20-preX-acX IIRC.

On Wed, 30 Jul 2003 09:58, Ond?ej Surý wrote:
> This is original code from udp.c:
>
> for(sk = udp_hash[hnum & (UDP_HTABLE_SIZE - 1)]; sk != NULL; sk
> = sk->next) {
> if(sk->num == hnum && !ipv6_only_sock(sk)) {
> int score;
> #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
> score = sk->family == PF_INET ? 1 : 0;
> #else
> score = 1;
> #endif
> /* 1 */
> if(sk->rcv_saddr) {
> if(sk->rcv_saddr != daddr)
> continue;
> score+=2;
> }
> if(sk->daddr) {
> if(sk->daddr != saddr)
> continue;
> score+=2;
> }
> if(sk->dport) {
> if(sk->dport != sport)
> continue;
> score+=2;
> }
> if(sk->bound_dev_if) {
> if(sk->bound_dev_if != dif)
> continue;
> score+=2;
> }
> if(score == 9) {
> result = sk;
> break;
> } else if(score > badness) {
> result = sk;
> badness = score;
> }
> /* 2 */
> }
> }
>
>
> Patch for this chunk is:
>
> ***************
> *** 226,229 ****
> --- 241,250 ----
> score = sk->family == PF_INET ? 1 : 0;
> #else
> + }else if (sk->ip_info != NULL){
> + if (udp_in_list (sk->ip_info,daddr)){
> + score++;
> + }else{
> + continue;
> + }
> score = 1;
> #endif
>
>
> There is two problems I see:
>
> 1. It broke logical flow of program, when sk->num == hnum &&
> !ipv6_only_sock(sk) is true then code marked between /*1*/ and /*2*/
> never executes, which is not true for original code.
>
> 2. because 1., score variable is not available for code in patch and
> rest of code manipulating with score variable.
>
> 3. score is used uninitalized when 2. is fixed by moving int score line
> before if line.
>
> Could someone look at that and produce correct patch?

-- 
Sam Vilain, sam_at_vilain.net

Seeing a murder on television... can help work off one's antagonisms. And if you haven't any antagonisms, the commercials will give you some. -- Alfred Hitchcock


About this list Date view Thread view Subject view Author view Attachment view
[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Wed 30 Jul 2003 - 14:29:09 BST by hypermail 2.1.3