[MDEV-29862] Extracting a subnet from IPv4 with INET6_NTOA & INET6_ATON Created: 2022-10-24  Updated: 2022-10-26  Resolved: 2022-10-26

Status: Closed
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 10.5.15
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Arno Assignee: Sergei Golubchik
Resolution: Not a Bug Votes: 0
Labels: None
Environment:

CentOS 3.10 x86_64
cacti 1.2.22 (if needed)



 Description   

I have an issue to extract the subnet part of an IPv4 based on the subnet mask and the ip adress.
In my DB the ip adress are of type varbinary(16) and the ip is stored using INET6_ATON

I'm using this Mysql function to test it:

this one work:
select INET_NTOA(INET_ATON("255.255.0.0")&INET_ATON("10.65.1.2" ))
return: 10.65.0.0

This don't :
select INET6_NTOA(INET6_ATON("255.255.0.0")&INET6_ATON("10.65.1.2" ))
return: null

And I need the record be able to handle either IPv4 and IPv6.
Is that the problem of 64 vs 128bit whay to handle the & function ?



 Comments   
Comment by Sergei Golubchik [ 2022-10-26 ]

This is not a bug. Operator & works with integers, and INET6_ATON returns a string, see https://mariadb.com/kb/en/inet6_aton/

Generated at Thu Feb 08 10:11:51 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.