Kernel Newbies archive on lore.kernel.org
 help / color / Atom feed
* Understanding the working of Optimistic DAD Feature.
@ 2020-02-06 12:19 Chinmay Agarwal
  2020-02-06 17:12 ` Valdis Klētnieks
  0 siblings, 1 reply; 2+ messages in thread
From: Chinmay Agarwal @ 2020-02-06 12:19 UTC (permalink / raw)
  To: Kernelnewbies

[-- Attachment #1.1: Type: text/plain, Size: 1794 bytes --]

Hi Team,

Had a doubt regarding Optimistic DAD implementation in linux kernel.


The RFC of Optimistic DAD states:



"Section 3.3

        A router SHOULD NOT configure an Optimistic Address."

To check the same there is a condition in kernel code wherein we check if ipv6.devconf_all is set.
Now, my query is that we are checking if forwarding is enabled on all interfaces, then we consider the system to be a router.
But even if forwarding is enabled from few interfaces(not all) isn't the system behaving like a router?


void addrconf_add_linklocal<https://elixir.bootlin.com/linux/latest/ident/addrconf_add_linklocal>(struct inet6_dev<https://elixir.bootlin.com/linux/latest/ident/inet6_dev> *idev<https://elixir.bootlin.com/linux/latest/ident/idev>,

                     const struct in6_addr<https://elixir.bootlin.com/linux/latest/ident/in6_addr> *addr, u32<https://elixir.bootlin.com/linux/latest/ident/u32> flags)

{

  .

  .

  .

  .



#ifdef<https://elixir.bootlin.com/linux/latest/ident/ifdef> CONFIG_IPV6_OPTIMISTIC_DAD

  if ((dev_net<https://elixir.bootlin.com/linux/latest/ident/dev_net>(idev<https://elixir.bootlin.com/linux/latest/ident/idev>->dev)->ipv6.devconf_all->optimistic_dad ||

       idev<https://elixir.bootlin.com/linux/latest/ident/idev>->cnf.optimistic_dad) &&

      !dev_net<https://elixir.bootlin.com/linux/latest/ident/dev_net>(idev<https://elixir.bootlin.com/linux/latest/ident/idev>->dev)->ipv6.devconf_all->forwarding<https://elixir.bootlin.com/linux/latest/ident/forwarding>)

          cfg<https://elixir.bootlin.com/linux/latest/ident/cfg>.ifa_flags |= IFA_F_OPTIMISTIC<https://elixir.bootlin.com/linux/latest/ident/IFA_F_OPTIMISTIC>;

#endif



  .

  .

  .

  .

}

Thanks
Chinmay


[-- Attachment #1.2: Type: text/html, Size: 12334 bytes --]

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}
pre
	{mso-style-priority:99;
	mso-style-link:"HTML Preformatted Char";
	margin:0in;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:"Courier New";}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
span.wordsection1Char
	{mso-style-name:"wordsection1 Char";
	mso-style-priority:99;
	mso-style-link:wordsection1;
	font-family:"Calibri",sans-serif;}
p.wordsection1, li.wordsection1, div.wordsection1
	{mso-style-name:wordsection1;
	mso-style-priority:99;
	mso-style-link:"wordsection1 Char";
	margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
span.HTMLPreformattedChar
	{mso-style-name:"HTML Preformatted Char";
	mso-style-priority:99;
	mso-style-link:"HTML Preformatted";
	font-family:"Courier New";}
span.kt
	{mso-style-name:kt;}
span.nf
	{mso-style-name:nf;}
span.p
	{mso-style-name:p;}
span.k
	{mso-style-name:k;}
span.n
	{mso-style-name:n;}
span.o
	{mso-style-name:o;}
span.cp
	{mso-style-name:cp;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri",sans-serif;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hi Team,<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Had a doubt regarding Optimistic DAD implementation in linux kernel.<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="wordsection1">The RFC of Optimistic DAD states:<o:p></o:p></p>
<p class="wordsection1"><o:p>&nbsp;</o:p></p>
<p class="wordsection1" style="text-indent:.5in">&#8220;Section 3.3<o:p></o:p></p>
<p class="wordsection1"><span style="font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A router SHOULD NOT configure an Optimistic Address.&#8221;</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">To check the same there is a condition in kernel code wherein we check if ipv6.devconf_all is set.<o:p></o:p></p>
<p class="MsoNormal">Now, my query is that we are checking if forwarding is enabled on all interfaces, then we consider the system to be a router.<o:p></o:p></p>
<p class="MsoNormal"><b>But even if forwarding is enabled from few interfaces(not all) isn&#8217;t the system behaving like a router?<o:p></o:p></b></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<pre style="margin-left:.5in"><span class="kt"><span style="color:#333399">void</span></span><span style="color:black"> </span><span class="nf"><span style="color:#0066BB"><a href="https://elixir.bootlin.com/linux/latest/ident/addrconf_add_linklocal"><b><span style="background:#F4F6FF">addrconf_add_linklocal</span></b></a></span></span><span class="p"><span style="color:#666666">(</span></span><span class="k"><span style="color:#008800">struct</span></span><span style="color:black"> <span class="n"><a href="https://elixir.bootlin.com/linux/latest/ident/inet6_dev"><b><span style="background:#F4F6FF">inet6_dev</span></b></a></span> </span><span class="o"><span style="color:#666666">*</span></span><span class="n"><span style="color:black"><a href="https://elixir.bootlin.com/linux/latest/ident/idev"><b><span style="background:#F4F6FF">idev</span></b></a></span></span><span class="p"><span style="color:#666666">,</span></span><span style="color:black"><o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</span><span class="k"><span style="color:#008800">const</span></span><span style="color:black"> </span><span class="k"><span style="color:#008800">struct</span></span><span style="color:black"> <span class="n"><a href="https://elixir.bootlin.com/linux/latest/ident/in6_addr"><b><span style="background:#F4F6FF">in6_addr</span></b></a></span> </span><span class="o"><span style="color:#666666">*</span></span><span class="n"><span style="color:black">addr</span></span><span class="p"><span style="color:#666666">,</span></span><span style="color:black"> <span class="n"><a href="https://elixir.bootlin.com/linux/latest/ident/u32"><b><span style="background:#F4F6FF">u32</span></b></a></span> <span class="n">flags</span></span><span class="p"><span style="color:#666666">)</span></span><span style="color:black"><o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span class="p"><span style="color:#666666">{</span></span><span style="color:black"><o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span style="color:black">&nbsp; .<o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span style="color:black">&nbsp; .<o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span style="color:black">&nbsp; .<o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span style="color:black">&nbsp; .<o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span style="color:black"><o:p>&nbsp;</o:p></span></pre>
<pre style="margin-left:.5in"><span class="cp"><span style="color:#557799">#<a href="https://elixir.bootlin.com/linux/latest/ident/ifdef"><b><span style="background:#F4F6FF">ifdef</span></b></a> CONFIG_IPV6_OPTIMISTIC_DAD</span></span><span style="color:black"><o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span style="color:black">&nbsp; </span><span class="k"><span style="color:#008800">if</span></span><span style="color:black"> </span><span class="p"><span style="color:#666666">((</span></span><span class="n"><span style="color:black"><a href="https://elixir.bootlin.com/linux/latest/ident/dev_net"><b><span style="background:#F4F6FF">dev_net</span></b></a></span></span><span class="p"><span style="color:#666666">(</span></span><span class="n"><span style="color:black"><a href="https://elixir.bootlin.com/linux/latest/ident/idev"><b><span style="background:#F4F6FF">idev</span></b></a></span></span><span class="o"><span style="color:#666666">-&gt;</span></span><span class="n"><span style="color:black">dev</span></span><span class="p"><span style="color:#666666">)</span></span><span class="o"><span style="color:#666666">-&gt;</span></span><span class="n"><span style="color:black">ipv6</span></span><span class="p"><span style="color:#666666">.</span></span><span class="n"><span style="color:black">devconf_all</span></span><span class="o"><span style="color:#666666">-&gt;</span></span><span class="n"><span style="color:black">optimistic_dad</span></span><span style="color:black"> </span><span class="o"><span style="color:#666666">||</span></span><span style="color:black"><o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span style="color:black">&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<span class="n"><a href="https://elixir.bootlin.com/linux/latest/ident/idev"><b><span style="background:#F4F6FF">idev</span></b></a></span></span><span class="o"><span style="color:#666666">-&gt;</span></span><span class="n"><span style="color:black">cnf</span></span><span class="p"><span style="color:#666666">.</span></span><span class="n"><span style="color:black">optimistic_dad</span></span><span class="p"><span style="color:#666666">)</span></span><span style="color:black"> </span><span class="o"><span style="color:#666666">&amp;&amp;</span></span><span style="color:black"><o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span style="color:black">&nbsp; &nbsp;&nbsp; &nbsp;</span><span class="o"><span style="color:#666666;background:yellow;mso-highlight:yellow">!</span></span><span class="n"><span style="color:black;background:yellow;mso-highlight:yellow"><a href="https://elixir.bootlin.com/linux/latest/ident/dev_net"><b>dev_net</b></a></span></span><span class="p"><span style="color:#666666;background:yellow;mso-highlight:yellow">(</span></span><span class="n"><span style="color:black;background:yellow;mso-highlight:yellow"><a href="https://elixir.bootlin.com/linux/latest/ident/idev"><b>idev</b></a></span></span><span class="o"><span style="color:#666666;background:yellow;mso-highlight:yellow">-&gt;</span></span><span class="n"><span style="color:black;background:yellow;mso-highlight:yellow">dev</span></span><span class="p"><span style="color:#666666;background:yellow;mso-highlight:yellow">)</span></span><span class="o"><span style="color:#666666;background:yellow;mso-highlight:yellow">-&gt;</span></span><span class="n"><span style="color:black;background:yellow;mso-highlight:yellow">ipv6</span></span><span class="p"><span style="color:#666666;background:yellow;mso-highlight:yellow">.</span></span><span class="n"><span style="color:black;background:yellow;mso-highlight:yellow">devconf_all</span></span><span class="o"><span style="color:#666666;background:yellow;mso-highlight:yellow">-&gt;</span></span><span class="n"><span style="color:black;background:yellow;mso-highlight:yellow"><a href="https://elixir.bootlin.com/linux/latest/ident/forwarding"><b>forwarding</b></a></span></span><span class="p"><span style="color:#666666;background:yellow;mso-highlight:yellow">)</span></span><span style="color:black;background:yellow;mso-highlight:yellow"><o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span style="color:black;background:yellow;mso-highlight:yellow">&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="n"><a href="https://elixir.bootlin.com/linux/latest/ident/cfg"><b>cfg</b></a></span></span><span class="p"><span style="color:#666666;background:yellow;mso-highlight:yellow">.</span></span><span class="n"><span style="color:black;background:yellow;mso-highlight:yellow">ifa_flags</span></span><span style="color:black;background:yellow;mso-highlight:yellow"> </span><span class="o"><span style="color:#666666;background:yellow;mso-highlight:yellow">|=</span></span><span style="color:black;background:yellow;mso-highlight:yellow"> <span class="n"><a href="https://elixir.bootlin.com/linux/latest/ident/IFA_F_OPTIMISTIC"><b>IFA_F_OPTIMISTIC</b></a></span></span><span class="p"><span style="color:#666666;background:yellow;mso-highlight:yellow">;</span></span><span style="color:black"><o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span class="cp"><span style="color:#557799">#endif</span></span><span style="color:black"><o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span style="color:black"><o:p>&nbsp;</o:p></span></pre>
<pre style="margin-left:.5in"><span style="color:black">&nbsp; .<o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span style="color:black">&nbsp; .<o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span style="color:black">&nbsp; .<o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span style="color:black">&nbsp; .<o:p></o:p></span></pre>
<pre style="margin-left:.5in"><span class="p"><span style="color:#666666">}</span></span><span style="color:black"><o:p></o:p></span></pre>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Thanks <o:p></o:p></p>
<p class="MsoNormal">Chinmay<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Understanding the working of Optimistic DAD Feature.
  2020-02-06 12:19 Understanding the working of Optimistic DAD Feature Chinmay Agarwal
@ 2020-02-06 17:12 ` Valdis Klētnieks
  0 siblings, 0 replies; 2+ messages in thread
From: Valdis Klētnieks @ 2020-02-06 17:12 UTC (permalink / raw)
  To: Chinmay Agarwal; +Cc: Kernelnewbies

[-- Attachment #1.1: Type: text/plain, Size: 888 bytes --]

On Thu, 06 Feb 2020 12:19:26 +0000, Chinmay Agarwal said:

> To check the same there is a condition in kernel code wherein we check if ipv6.devconf_all is set.
> Now, my query is that we are checking if forwarding is enabled on all interfaces, then we consider the system to be a router.

> But even if forwarding is enabled from few interfaces(not all) isn't the system behaving like a router?

You can't actually configure "routing on some but not all" without setting the
global forwarding bit.

If you have the very odd use case where you have eth0, eth1, and eth2, and
you're routing between eth0 and eth1, but eth2 is a private net that should
*not* communicate with either eth0 or eth1, the way you configure that is to
turn on the global forwarding bit, and then use a combo of routing table and
firewall rules to prevent traffic going to eth2 unless it's from the local
host.




[-- Attachment #1.2: Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-06 12:19 Understanding the working of Optimistic DAD Feature Chinmay Agarwal
2020-02-06 17:12 ` Valdis Klētnieks

Kernel Newbies archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kernelnewbies/0 kernelnewbies/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernelnewbies kernelnewbies/ https://lore.kernel.org/kernelnewbies \
		kernelnewbies@kernelnewbies.org
	public-inbox-index kernelnewbies

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernelnewbies.kernelnewbies


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git