Imp.ListenPacket fail for IPv6 address

42 views
Skip to first unread message

Serguei Bezverkhi (sbezverk)

unread,
Oct 10, 2019, 12:38:26 AM10/10/19
to golan...@googlegroups.com

Hello,

 

Here is the part of code where I attempt to listen for icmp packet in a namespace. The same code is used for IPv4 and IPv6, only proto and scr are differ depending on ipv4 or ipv6 mode.

For IPv4 address code work as expected but for IPv6 ListenPacket fails.

 

                org, err := netns.Get()

                if err != nil {

                                return err

                }

                defer netns.Set(org)

                if err := netns.Set(sourceNS); err != nil {

                                return err

                }

 

                c, err := icmp.ListenPacket(proto, src)

                if err != nil {

                                return fmt.Errorf("call ListenPacket failed with error: %+v", err)

                }

                defer c.Close()

 

ListenPacket fails with: “call ListenPacket failed with error: listen ip6:ipv6-icmp 2001:1::1: bind: cannot assign requested address”

 

Here is how proto and src looks like for IPv6:

 

Proto: ip6:ipv6-icmp Address: 2001:1::1

 

I confirmed that namespace has veth interface with right ipv6 address.

 

Links found in the namespace, as you can see ipv6 address I am trying to bind ListenPacket is present.

 

Link: lo

Link: veth-1-612de81e

- 2001:1::1

 

Appreciate some ideas what I do wrong for ipv6 case.

Thank you

Serguei

Reply all
Reply to author
Forward
0 new messages