[apparmor] [patch 4/5] add generic lookup of af_name mappings

Seth Arnold seth.arnold at canonical.com
Thu Aug 7 23:17:25 UTC 2014


On Wed, Aug 06, 2014 at 05:32:48AM -0700, john.johansen at canonical.com wrote:
> Signed-off-by: John Johansen <john.johansen at canonical.com>

Looks good in itself, but I noticed that the network_families array is
missing values 0, 12, 27, and 28 when built on my trusty laptop. So, uh, is
'return i' and 'return network_families[af]' correct in face of holes?

Thanks

> ---
>  parser/network.c |   19 +++++++++++++++++++
>  parser/network.h |    5 +++++
>  2 files changed, 24 insertions(+)
> 
> --- 2.9-test.orig/parser/network.c
> +++ 2.9-test/parser/network.c
> @@ -305,6 +305,25 @@
>  #include "af_names.h"
>  };
>  
> +int net_find_af_val(const char *af)
> +{
> +	int i;
> +	for (i = 0; network_families[i]; i++) {
> +		if (strcmp(network_families[i], af) == 0)
> +			return i;
> +	}
> +
> +	return -1;
> +}
> +
> +const char *net_find_af_name(unsigned int af)
> +{
> +	if (af < 0 || af > get_af_max())
> +		return NULL;
> +
> +	return network_families[af];
> +}
> +
>  void __debug_network(unsigned int *array, const char *name)
>  {
>  	unsigned int count = sizeof(sock_types)/sizeof(sock_types[0]);
> --- 2.9-test.orig/parser/network.h
> +++ 2.9-test/parser/network.h
> @@ -77,5 +77,10 @@
>  
>  int net_find_type_val(const char *type);
>  const char *net_find_type_name(int type);
> +int net_find_af_val(const char *af);
> +const char *net_find_af_name(unsigned int af);
> +const struct network_tuple *net_find_mapping(const char *family,
> +					     const char *type,
> +					     const char *protocol);
>  
>  #endif /* __AA_NETWORK_H */
> 
> 
> -- 
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20140807/1d8be73f/attachment.pgp>


More information about the AppArmor mailing list