diff mbox

[iproute2] iproute2: Fix batch-mode for mrules.

Message ID 1279234090-18624-1-git-send-email-greearb@candelatech.com
State Accepted, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Ben Greear July 15, 2010, 10:48 p.m. UTC
The do_multirule logic was broken in batch mode because
it expected the preferred_family to be AF_INET or AF_INET6,
but it then assigned it to RTNL_FAMILY_IPMR or RTNL_FAMILY_IP6MR.
So, the next iteration of the batch processing, it failed
the check for AF_INET or AF_INET6.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
:100644 100644 9c8c6ef... d3b97e2... M	ip/iprule.c
 ip/iprule.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

Comments

stephen hemminger July 23, 2010, 4:03 p.m. UTC | #1
On Thu, 15 Jul 2010 15:48:10 -0700
Ben Greear <greearb@candelatech.com> wrote:

> The do_multirule logic was broken in batch mode because
> it expected the preferred_family to be AF_INET or AF_INET6,
> but it then assigned it to RTNL_FAMILY_IPMR or RTNL_FAMILY_IP6MR.
> So, the next iteration of the batch processing, it failed
> the check for AF_INET or AF_INET6.
> 
> Signed-off-by: Ben Greear <greearb@candelatech.com>
> ---
> :100644 100644 9c8c6ef... d3b97e2... M	ip/iprule.c
>  ip/iprule.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/ip/iprule.c b/ip/iprule.c
> index 9c8c6ef..d3b97e2 100644
> --- a/ip/iprule.c
> +++ b/ip/iprule.c
> @@ -446,8 +446,12 @@ int do_multirule(int argc, char **argv)
>  	case AF_INET6:
>  		preferred_family = RTNL_FAMILY_IP6MR;
>  		break;
> +	case RTNL_FAMILY_IPMR:
> +	case RTNL_FAMILY_IP6MR:
> +		break;
>  	default:
> -		fprintf(stderr, "Multicast rules are only supported for IPv4/IPv6\n");
> +		fprintf(stderr, "Multicast rules are only supported for IPv4/IPv6, was: %i\n",
> +			preferred_family);
>  		exit(-1);
>  	}
>  

Applied
Ben Greear July 23, 2010, 4:09 p.m. UTC | #2
On 07/23/2010 09:03 AM, Stephen Hemminger wrote:
> On Thu, 15 Jul 2010 15:48:10 -0700
> Ben Greear<greearb@candelatech.com>  wrote:
>
>> The do_multirule logic was broken in batch mode because
>> it expected the preferred_family to be AF_INET or AF_INET6,
>> but it then assigned it to RTNL_FAMILY_IPMR or RTNL_FAMILY_IP6MR.
>> So, the next iteration of the batch processing, it failed
>> the check for AF_INET or AF_INET6.
>>
>> Signed-off-by: Ben Greear<greearb@candelatech.com>
>> ---
>> :100644 100644 9c8c6ef... d3b97e2... M	ip/iprule.c
>>   ip/iprule.c |    6 +++++-
>>   1 files changed, 5 insertions(+), 1 deletions(-)
>>
>> diff --git a/ip/iprule.c b/ip/iprule.c
>> index 9c8c6ef..d3b97e2 100644
>> --- a/ip/iprule.c
>> +++ b/ip/iprule.c
>> @@ -446,8 +446,12 @@ int do_multirule(int argc, char **argv)
>>   	case AF_INET6:
>>   		preferred_family = RTNL_FAMILY_IP6MR;
>>   		break;
>> +	case RTNL_FAMILY_IPMR:
>> +	case RTNL_FAMILY_IP6MR:
>> +		break;
>>   	default:
>> -		fprintf(stderr, "Multicast rules are only supported for IPv4/IPv6\n");
>> +		fprintf(stderr, "Multicast rules are only supported for IPv4/IPv6, was: %i\n",
>> +			preferred_family);
>>   		exit(-1);
>>   	}
>>
>
> Applied

Thanks.  I recently realized this patch is not quite enough
for full flexibility.

It does help the case where you have 'normal' cmds followed by
mrule commands, but it doesn't fix the case where you have 'normal' commands
after the mrule commands.

I was thinking maybe we should pass the preferred_family in as an argument
to the method(s) instead of twiddling the global value?

Thanks,
Ben
diff mbox

Patch

diff --git a/ip/iprule.c b/ip/iprule.c
index 9c8c6ef..d3b97e2 100644
--- a/ip/iprule.c
+++ b/ip/iprule.c
@@ -446,8 +446,12 @@  int do_multirule(int argc, char **argv)
 	case AF_INET6:
 		preferred_family = RTNL_FAMILY_IP6MR;
 		break;
+	case RTNL_FAMILY_IPMR:
+	case RTNL_FAMILY_IP6MR:
+		break;
 	default:
-		fprintf(stderr, "Multicast rules are only supported for IPv4/IPv6\n");
+		fprintf(stderr, "Multicast rules are only supported for IPv4/IPv6, was: %i\n",
+			preferred_family);
 		exit(-1);
 	}