Kernel Newbies archive on lore.kernel.org
 help / color / Atom feed
From: Chinmay Agarwal <chinagar@qti.qualcomm.com>
To: "Kernelnewbies@kernelnewbies.org" <Kernelnewbies@kernelnewbies.org>
Subject: Understanding the working of Optimistic DAD Feature.
Date: Thu, 6 Feb 2020 12:19:26 +0000
Message-ID: <DM6PR02MB47791D09F641777AFAC0FA8BEB1D0@DM6PR02MB4779.namprd02.prod.outlook.com> (raw)

[-- 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

             reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-06 12:19 Chinmay Agarwal [this message]
2020-02-06 17:12 ` Valdis Klētnieks

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM6PR02MB47791D09F641777AFAC0FA8BEB1D0@DM6PR02MB4779.namprd02.prod.outlook.com \
    --to=chinagar@qti.qualcomm.com \
    --cc=Kernelnewbies@kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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